Is it possible to set config settings on Firefox from a Addon

两盒软妹~` 提交于 2019-12-04 05:59:15

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)

(taken from this snippet).

One way is to provide your own implementation of the printing prompt service. You could then inspect the window being printed and turn on silent printing if you want to bypass the print dialog. You might need to retrieve the original service to handle the cases that you don't want to. I couldn't find much documentation but there's some related documentation here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!