是否可以通过插件在Firefox上设置配置设置 [英] Is it possible to set config settings on Firefox from a Addon

查看:206
本文介绍了是否可以通过插件在Firefox上设置配置设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从Web打印而不提示打印对话框的方法(

I'm looking for a way to print from web without prompting the print dialog (I just made the question).

我发现

I found This method for Firefox and it seems to work, but it obviously will affect all websites. So I'm thinking of developing a Firefox Addon that makes this configuration to affect only specific websites.

我对构建Firefox插件一无所知,但是如果可以通过这种方式更改设置,我将学习如何做.

I don't know nothing about building Firefox addons, but if it's possible to change settings this way I will learn how to do it.

所以我的问题是..是否可以在Addon和特定网站的Firefox上设置配置设置?

So my question is.. Is it possible to set config settings on Firefox from a Addon and for specific websites?

非常感谢.

推荐答案

如果您要开发Firefox插件,则可以轻松地"替换打印按钮并委托普通网站上的标准打印操作.对于URL列表(即您的网站),您可以将print.always_print_silent临时设置为true并完成操作.

If you are going to develop a Firefox addon you could "easily" replace the print button and delegate to the standard print action on normal websites. For a list of URLs, i.e. your web site, you temporarily set print.always_print_silent to true and be done with it.

要在插件中修改首选项,您将像这样:

For modifying a preference in an addon you would something like this:

// Get the "accessibility." branch
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
    .getService(Components.interfaces.nsIPrefService).getBranch("accessibility.");

// prefs is an nsIPrefBranch.
// Look in the above section for examples of getting one.
var value = prefs.getBoolPref("typeaheadfind"); 

// get a pref (accessibility.typeaheadfind)
prefs.setBoolPref("typeaheadfind", !value); // set a pref (accessibility.typeaheadfind)

(摘自以下代码段).

这篇关于是否可以通过插件在Firefox上设置配置设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆