GMCommonAPI.js

GM Common API (GMC) is a simple library designed for easily adding Greasemonkey 4 compatibilty to existing userscripts

Per 28-10-2017. Zie de nieuwste versie.

Dit script moet niet direct worden geïnstalleerd - het is een bibliotheek voor andere scripts om op te nemen met de meta-richtlijn // @require https://update.greasyfork.org/scripts/34527/226657/GMCommonAPIjs.js

Maker
Stig Nygaard
Versie
0.0.1.20171028101428
Gemaakt op
25-10-2017
Bijgewerkt op
28-10-2017
Grootte
12 KB
Licentie
N.v.t.

GM Common Library (GMC) is an API designed for easily adding Greasemonkey 4 compatibility to existing userscripts.

GMC provides a common subset of the functionality offered by the new "asynchronous API" in Greasemonkey 4 (GM.*) and the classic "synchronous API" from other userscript managers (GM_*), offered in a single "classic" synchronous API (GMC.*).

With the introduction of the Greasemonkey 4 WebExtension (currently in beta), the classic GM_* "synchronous" API is replaced with a new GM.* "asynchronous API". The features of the new API in Greasemonkey 4 (GM4) are very similar to the classic API, but the functions are asynchronous. This means you might need to (learn asynchronous programming and) do some refactoring of your existing userscripts to make use of the new API in GM4.

As an alternative to refactoring your code, GMC offers a "synchronous subset" of the GM APIs, which works with scripts running in both the new GM4, in the older versions of Greasemonkey, and in other userscript managers like Tampermonkey and Violentmonkey. Where APIs are supported in GMC, no refactoring of your script is needed; Simply add GMC @require/@grants statements in meta-block of your userscript, and replace the use of GM_* methods with equivalent GMC.* methods.

For more info, see GitHub repository or the source code.