sizzle / gm4-polyfill

Published:

Version: 20171114.0.0 updated

Summary: This helper script bridges compatibility between the Greasemonkey 4 APIs and existing/legacy APIs.

Copyright: 2017, Anthony Lieuallen (https://github.com/arantius)

License: MIT; https://raw.githubusercontent.com/greasemonkey/gm4-polyfill/master/LICENSE

Collaborator: Marti

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

1 Votes
-1