GM.setValue: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(remove "in older versions ...", just describe current version)
m (Arantius moved page GM setValue to GM.setValue: Greasemonkey 4.0)
(No difference)

Revision as of 14:30, 3 November 2017


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.