The dupe candidate is for previous GM versions. The problem is likely somewhere around the different scopes where the userscripts can run, as described here. However, as described here, this functionality is currently undocumented for Greasemonkey 4.0.
I have this Greasemonkey demo script:
// ==UserScript==
// @name GM_getValue, GM_setValue don't work demo
// @version 0.2
// @author You
// @include /^https:\/\/stackoverflow.com/$/
// @grant GM_getValue
// @grant GM_setValue
// @run-at document-end
// ==/UserScript==
console.log('script started');
var id = GM_getValue('testName', 0);
console.log('got ' + id);
id++;
GM_setValue('testName', id);
Calling this with the https://stackoverflow.com/, it is well visible that it is called.
However, I get this error on the console:
Script error:
ReferenceError: GM_getValue is not defined
Stack trace:
userScript@user-script:demosrv/GM_getValue%2C%20GM_setValue%20don%27t%20work%20demo:372:5
scopeWrapper@user-script:demosrv/GM_getValue%2C%20GM_setValue%20don%27t%20work%20demo:381:9
@user-script:demosrv/GM_getValue%2C%20GM_setValue%20don%27t%20work%20demo:361:17
I've digged docs a lot, but it seems GM_{get,set}Value
simply don't want to exist.
Why is it so? How to make it working?
I am using Firefox.