Skip to content

Commit 6c8ef4c

Browse files
committed
Fix greasemonkey issues (#8)
1 parent ae1ef90 commit 6c8ef4c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tampermonkey.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// @license MIT
1212
// @match *://*/*
1313
// @run-at document-start
14-
// @grant GM_setValue
15-
// @grant GM_getValue
14+
// @grant GM.setValue
15+
// @grant GM.getValue
1616
// ==/UserScript==
1717

18-
((document) => {
18+
(async (document) => {
1919
'use strict';
2020
let fastNode;
2121
let failed;
@@ -36,7 +36,6 @@
3636
const TEST_PATH = '/gh/PipecraftNet/jsdelivr-auto-fallback@main/empty.css?';
3737
const shouldReplace = (text) => text && text.includes(PREFIX + SOURCE);
3838
const replace = (text) => text.replace(PREFIX + SOURCE, PREFIX + fastNode);
39-
const setTimeout = window.setTimeout;
4039
const $ = document.querySelectorAll.bind(document);
4140

4241
const replaceElementSrc = () => {
@@ -124,10 +123,9 @@
124123
document.head.insertAdjacentElement('afterbegin', newNode);
125124
};
126125

127-
const cached = (() => {
126+
const cached = await (async () => {
128127
try {
129-
// eslint-disable-next-line new-cap
130-
return Object.assign({}, GM_getValue(STORE_KEY));
128+
return Object.assign({}, await GM.getValue(STORE_KEY));
131129
} catch {
132130
return {};
133131
}
@@ -165,8 +163,7 @@
165163
tryReplace();
166164
}
167165

168-
// eslint-disable-next-line new-cap
169-
GM_setValue(STORE_KEY, cached);
166+
GM.setValue(STORE_KEY, cached);
170167
}, TIMEOUT + 100);
171168
};
172169

0 commit comments

Comments
 (0)