NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
Vetted and adopted initially from unlicensed here then licensed here.
This helper script bridges compatibility between the Greasemonkey 4 APIs and existing/legacy APIs. Say for example your user script includes:
// @grant GM_getValue
... and you'd like to be compatible with both Greasemonkey 3 and Greasemonkey 4 (and for that matter all versions of Violentmonkey, Tampermonkey, and any other user script engine) Add:
// @grant GM.getValue
// @require https://openuserjs.org/src/libs/sizzle/gm4-polyfill.js
... and switch to the new (GM-dot) APIs, which return promises. If your script is running in an engine that does not provide the new asynchronous APIs, this helper will add them, based on the old APIs.
If you use await
at the top level, you'll need to wrap your script in an async
function to be compatible with any user script engine besides Greasemonkey 4.
(async () => {
let x = await GM.getValue('x');
})();
Rating: 1