Menu

GM_setValue

mmartz

Description

This API method allows user script authors to persist simple values locally.

Currently values are set in a SQLite database located in the Scripts directory. Each script currently has one database named off of the subfolder created after installing a script with a file extension of .db.

Prior to version 1.13 Numbers were limited to integers and no decimal values. Values were deleted from the Firefox preferences back end and could be manually changed by typing about:config?filter=extensions.greasemonkey.scriptvals.namespace/name.foo

Prior to version 3.2 simple data objects, such as JSON, were not allowed.

| Examples | See Also | Notes

Syntax

GM_setValue( name, value )

Value: Function
Returns: undefined
Compatibility: Greasemonkey 0.3b - 3.12.0
Access: @grant

Parameters

Properties
name value
  • All properties are optional except name and value.

Properties


name

Value: String
Usage: name = "PropertyName";

  • Property name to retrieve or create.

value

Value: String, Number, Boolean, or JSON
Usage: value = 5;

Examples

Core

GM_setValue("foo", 5);

or

GM_setValue("foo", 3.14159);

or

GM_setValue("foo", "bar");

or

GM_setValue("foo", true);

or

GM_setValue("foo", { hello : "world" });

See Also

Notes


Related

Wiki: GM_deleteValue
Wiki: GM_getValue
Wiki: GM_listValues
Wiki: Greasemonkey_Manual:API
Wiki: Scripts_directory
Wiki: Version_history

MongoDB Logo MongoDB