This book is badly out of date and will probably never be updated. You can find more up-to-date information on the Greasemonkey wiki.

Dive Into Greasemonkey

Teaching an old web new tricks

Name

GM_getValue — get script-specific configuration value

Synopsis

returntype GM_getValue(key, defaultValue);

Description

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.

[Tip]

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

History

GM_getValue was introduced in Greasemonkey 0.3.

See also

← GM_log
GM_setValue →