javascript - about config preferences and js -


I wonder if it is possible to get the value of certain defined preferences about: config using javascript?

The incentive Firefox is to get the value of the set preferences in Firefox, when I have created the user land on the Adon Front End. In fact, I'm trying to identify those users who are not coming to the EP without having to explicitly login.

Yes, you can.

First of all, you have to know that Mozilla uses the XPCOM interface for the preference system.

The three used interfaces are nsIPrefService , nsIPrefBranch and nsIPrefBranch2 .

The preferences service starts the way you intend to instantize in any way.

Two examples to illustrate this two:

  // Get the root branch pre prefix = components .classes ["@ mozilla.org/preferences- service; 1 "] .getService (Components.interfaces.nsIPrefBranch);  

. Get

  // "extensions.myext". Branch var prefs = Components.classes ["@ mozilla.org/preferences- service" 1]] .getService (Components.interfaces.nsIPrefService); Prefs = prefs.getBranch ("extensions.myext.");  

and it has 3 types of preferences, they are string , integer and boolean . There are six ways in getBoolPref () , setBoolPref () , getCharPref () , NSIPFBRF () , SetCharPref () , getIntPref () and setIntPref () .

Get more examples on it:

  // "Access". Branch var prefs = Components.classes ["@ mozilla.org/preferences- service.1"] .getService (Components.interfaces.nsIPrefService) .getBranch ("Access."); // prefes is a NSIPFRR.I see examples in the above section for examples of getting one // var value = prefs.getBoolPref ("TypeAheadFund"); // Get a pref (Accessibility.TipAheadFund) prefs.setBoolPref ("TypeAheadFund",! Value); // Set a prefix (Accessibility type type)  

You can also use complex types. Using NsISupportsString, that is used to handle strings in preferences, therefore, use this when the priority value can contain non-ASCII characters

Example:

  // prefs is an nsIPrefBranch / Example 1: Getting the Unicode value var value = prefs.getComplexValue ("preference.with.non.ascii.value", Components.interfaces.nsISupportsString). Data; // Example 2: Setting Unicode Value str = Components.classes ["@ mozilla.org/supports-string;1"] .createInstance (Components.interfaces.nsISupportsString); Str.data = "Some non-ESC text"; Prefs.setComplexValue ("preference.with.non.ascii.value", Components.interfaces.nsISupportsString, str);  

I hope you will solve your doubts on this.

More


Comments