Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

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.

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

Thanks a lot.

like image 259
Carlos Cardenas Avatar asked Apr 27 '11 19:04

Carlos Cardenas


People also ask

How do I add a config in Firefox?

Type about:config in the address bar and press Enter. A warning page may appear. Click Accept the Risk and Continue to go to the about:config page. Click Show All to view all preferences currently set in the profile or use the Search preference name box to filter the list.

How do I customize Firefox settings?

Firefox offers a built-in Configuration Editor, accessible by typing about:config in the address field, which provides access to hundreds of different features and settings you can enable, disable, or otherwise customize.

Does Firefox Sync about config?

Once you add this preference, the preference with the corresponding name will sync across all instances of Firefox desktop. If there's a preference that is available on Firefox Android, and you have sync enabled on it, it will sync to your phone as well. First, open the about:config page.


1 Answers

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).

like image 174
speedball2001 Avatar answered Oct 12 '22 01:10

speedball2001