GM_setValue

From GreaseSpot Wiki
Jump to: navigation, search


Description

This method allows user script authors to persist simple values across page-loads.

Strings, booleans, and integers are currently the only allowed data types.

Since Greasemonkey 1.13 values are saved per userscript in a SQLite database [1]. You can find the corresponding database by the userscript basedir as defined in the config.xml. The values are only accessible by opening the database is an SQLite reader, like add-on SQLite Manager.

Compatibility: Greasemonkey 0.3b+

Syntax

function GM_setValue( name, value )

Arguments

name
String The unique (within this script) name for this value. Should be restricted to valid Javascript identifier characters.
value
String, Integer or Boolean Any valid value of these types. Any other type may cause undefined behavior, including crashes.

Returns

undefined

Examples

Set the name foo to hold the value bar:

GM_setValue("foo", "bar");

See Also

References

  1. Corresponding ticket for moving to SQLite: #1798.