How/Where to store data in a Chrome Tampermonkey script?
It has the advantage of storing values cross-domain, as well.
Beware that the bog-standard
GM_setValue() is somewhat problematic on Firefox. It can cause a script instance to crash on invalid values -- So it's best to use a serializer, such as GM_SuperValue, to store anything but strings. Even innocent-looking integers can cause the default
GM_setValue() to crash.
GM_setValue(), cookies, localStorage, and IndexedDB are available for persistent data on both browsers.
IndexedDB would also probably do what you want, but it is nowhere as easy to use as
Nowadays, don't forget to use:
// @grant GM_setValue
// @grant GM_getValue
Also, if you do use the GM_SuperValue library, you would now add it with:
// @require http://userscripts-mirror.org/scripts/source/107941.user.js
in the metadata block. (Since userscripts.org is long dead.)