Is it possible to set configuration settings in Firefox from the addon

I am looking for a way to print from the Internet without asking for a print dialog ( I just posed a question ).

I found this method for Firefox and it seems to work, but it will obviously affect all websites, so I'm thinking of developing Firefox Addon, which forces this configuration to affect only certain websites.

I don’t know anything about creating Firefox add-ons, but if you can change the settings this way, I’ll learn how to do it.

So my question is: is it possible to set configuration settings in Firefox from the addon and for certain sites?

Many thanks.

+6
source share
2 answers

If you intend to create a Firefox add-on, you can easily replace the print button and delegate the standard print action to regular websites. For a list of URLs i.e. On your website, you temporarily set print.always_print_silent to true and executed it.

To change the preference in the addon, you will have 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 ).

+6
source

One way is to provide you with your own print service implementation. You can then check the printed window and enable silent printing if you want to bypass the print dialog. You may need to restore the original service to handle cases that you do not want. I could not find much documentation, but there is some related documentation there .

0
source

Source: https://habr.com/ru/post/886822/


All Articles