GM.listValues: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
m (Text replace - "{{Samp |1=<pre style="border: none; margin: inherit;">" to "<pre class='sample'>")
m (Text replace - "{{Good samp |1=<pre style="border: none; margin: inherit;">" to "<pre class='sample-good'>")
Line 30: Line 30:


An array of values used by a script:
An array of values used by a script:
{{Good samp |1=<pre style="border: none; margin: inherit;">
<pre class='sample-good'>
var vals = new Array();
var vals = new Array();
for each(var val in GM_listValues())
for each(var val in GM_listValues())
Line 37: Line 37:


Equivalent:
Equivalent:
{{Good samp |1=<pre style="border: none; margin: inherit;">
<pre class='sample-good'>
var vals = GM_listValues().map(GM_getValue);
var vals = GM_listValues().map(GM_getValue);
</pre>}}
</pre>}}

Revision as of 21:58, 3 February 2010


Description

This API method retrieves an array of preference names that start with the branch's root.

Values are retrieved from the Firefox preferences back end and can be manually viewed by typing about:config in the address bar and searching for the preference name "greasemonkey.scriptvals.namespace/name.".


Syntax

GM_listValues()

Value: Function
Returns: String Array
Compatibility: Greasemonkey 0.8.1+
Parameters
Properties
  • There are currently no properties.

Examples

GM_log(GM_listValues());

}}

An array of values used by a script:

var vals = new Array();
for each(var val in GM_listValues())
    vals.push(GM_getValue(val));

}}

Equivalent:

var vals = GM_listValues().map(GM_getValue);

}}

See Also