GM.setValue

From GreaseSpot Wiki
(Redirected from GM setValue)
Jump to: navigation, search

Description

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

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

Syntax

function GM_setValue( name, value )

Compatibility: Greasemonkey 4.0+

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

A Promise, resolved successfully with no value on success, rejected with no value on failure.

Examples

Set the name foo to hold the value bar:

GM.setValue("foo", "bar");

See Also