Dive Into Greasemonkey

Teaching an old web new tricks


GM_getValue — get script-specific configuration value


returntype GM_getValue(key, defaultValue);


GM_getValue retrieves a script-specific configuration value. The return value may be a string, boolean, or integer. The key argument is a string of no fixed format. The defaultValue argument is optional; if present, it will be returned if the requested key does not exist. If no defaultValue is given and the requested key does not exist, GM_getValue will return undefined.

Greasemonkey configuration values are similar to browser cookies, but there are important differences. Both are stored on the local machine, but while cookies are domain-specific and can only be accessed from their originating domain, Greasemonkey configuration values are script-specific and can only be accessed by the user script that created them (regardless of the address the user script is currently running on). And unlike cookies, configuration values are never transmitted to remote servers.


You can see all the stored configuration values by visiting about:config and filtering on greasemonkey.scriptvals.


GM_getValue was introduced in Greasemonkey 0.3.

See also

← GM_log
GM_setValue →