GM.setValue: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
m Added corresponding ticket |
remove "in older versions ...", just describe current version |
||
Line 7: | Line 7: | ||
Strings, booleans, and integers are currently the only allowed data types. | Strings, booleans, and integers are currently the only allowed data types. | ||
Since [[Version_history#1.13|Greasemonkey 1.13]] values are saved per userscript in a [https://developer.mozilla.org/en-US/docs/Storage SQLite] database <ref>Corresponding ticket for moving to SQLite: {{GitTicket|1798}}.</ref>. You can find the corresponding database by the userscript <code>basedir</code> as defined in the <code>[[config.xml]]</code>. The values are only accessible by opening the database is an SQLite reader, like add-on [https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/ SQLite Manager]. | |||
Compatibility: [[Version_history#0.3_beta|Greasemonkey 0.3b+]] | Compatibility: [[Version_history#0.3_beta|Greasemonkey 0.3b+]] |
Revision as of 14:52, 24 January 2014
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
orBoolean
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");