Improve syntax Greasemonkey 4 APIs
This commit is contained in:
parent
f9412b3ba4
commit
09eea77390
@ -1,23 +1,23 @@
|
||||
/*
|
||||
This helper script bridges compatibility between the Greasemonkey 4 APIs and
|
||||
existing/legacy APIs. Say for example your user script includes
|
||||
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:
|
||||
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://greasemonkey.github.io/gm4-polyfill/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.
|
||||
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.
|
||||
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');
|
||||
@ -101,7 +101,6 @@ Object.entries({
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Object.entries({
|
||||
'GM_addStyle': 'addStyle',
|
||||
'GM_deleteValue': 'deleteValue',
|
||||
|
Loading…
x
Reference in New Issue
Block a user