Skip to content

Commit 01c146b

Browse files
committed
Merge remote-tracking branch 'origin/develop/mv3' into release/mv3
2 parents 70554c7 + 865e5f6 commit 01c146b

20 files changed

Lines changed: 252 additions & 611 deletions

example/run-in/run-in_both.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ==UserScript==
2+
// @name Test @run-in both
3+
// @namespace https://bbs.tampermonkey.net.cn/
4+
// @version 0.1.0
5+
// @description @run-in normal-tabs & @run-in incognito-tabs 既注入正常标签又注入隐身标签
6+
// @author You
7+
// @match https://bbs.tampermonkey.net.cn/*
8+
// @run-in normal-tabs
9+
// @run-in incognito-tabs
10+
// ==/UserScript==
11+
console.log(GM_info.script["run-in"]);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ==UserScript==
2+
// @name Test @run-in incognito-tabs
3+
// @namespace https://bbs.tampermonkey.net.cn/
4+
// @version 0.1.0
5+
// @description @run-in incognito-tabs 只注入隐身标签
6+
// @author You
7+
// @match https://bbs.tampermonkey.net.cn/*
8+
// @run-in incognito-tabs
9+
// ==/UserScript==
10+
console.log(GM_info.script["run-in"]);

example/run-in/run-in_none.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// ==UserScript==
2+
// @name Test @run-in none
3+
// @namespace https://bbs.tampermonkey.net.cn/
4+
// @version 0.1.0
5+
// @description 不设置@run-in默认既注入正常标签又注入隐身标签
6+
// @author You
7+
// @match https://bbs.tampermonkey.net.cn/*
8+
// ==/UserScript==
9+
console.log(GM_info.script["run-in"]);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ==UserScript==
2+
// @name Test @run-in normal-tabs
3+
// @namespace https://bbs.tampermonkey.net.cn/
4+
// @version 0.1.0
5+
// @description @run-in normal-tabs 只注入正常标签
6+
// @author You
7+
// @match https://bbs.tampermonkey.net.cn/*
8+
// @run-in normal-tabs
9+
// ==/UserScript==
10+
console.log(GM_info.script["run-in"]);

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"coverage": "vitest run --coverage",
1212
"build": "cross-env NODE_ENV=production rspack build",
1313
"dev": "cross-env NODE_ENV=development rspack",
14+
"dev-noMap": "cross-env NODE_ENV=development NO_MAP=true rspack",
1415
"pack": "node ./scripts/pack.js",
1516
"format": "prettier --write .",
1617
"lint": "eslint .",
@@ -26,7 +27,7 @@
2627
"crypto-js": "^4.2.0",
2728
"dayjs": "^1.11.13",
2829
"dexie": "^4.0.10",
29-
"eslint-linter-browserify": "^7.32.0",
30+
"eslint-linter-browserify": "^9.26.0",
3031
"eventemitter3": "^5.0.1",
3132
"i18next": "^23.16.4",
3233
"monaco-editor": "^0.52.2",
@@ -65,7 +66,7 @@
6566
"eslint": "^9.24.0",
6667
"eslint-plugin-react": "^7.37.4",
6768
"eslint-plugin-react-hooks": "^5.2.0",
68-
"eslint-plugin-userscripts": "^0.2.12",
69+
"eslint-plugin-userscripts": "^0.5.6",
6970
"fake-indexeddb": "^6.0.0",
7071
"globals": "^16.0.0",
7172
"jsdom": "^25.0.1",
@@ -83,4 +84,4 @@
8384
"vitest": "^2.1.4"
8485
},
8586
"packageManager": "pnpm@10.8.0"
86-
}
87+
}

packages/eslint/compat-grant.js

Lines changed: 4 additions & 251 deletions
Original file line numberDiff line numberDiff line change
@@ -1,259 +1,12 @@
1-
// Fork from eslint-plugin-userscripts
2-
// Documentation:
3-
// - Tampermonkey: https://www.tampermonkey.net/documentation.php#_grant
4-
// - Violentmonkey: https://violentmonkey.github.io/api/gm
5-
// - Greasemonkey: https://wiki.greasespot.net/Greasemonkey_Manual:API
6-
// - ScriptCat: https://docs.scriptcat.org/docs/dev/cat-api/
1+
const compat_grant = require("eslint-plugin-userscripts/dist/data/compat-grant.js");
72
const compatMap = {
83
CAT_userConfig: [{ type: "scriptcat", versionConstraint: ">=0.11.0-beta" }],
94
CAT_fileStorage: [{ type: "scriptcat", versionConstraint: ">=0.11.0" }],
10-
"GM.addElement": [
11-
{ type: "tampermonkey", versionConstraint: ">=4.11.6113" },
12-
{ type: "violentmonkey", versionConstraint: ">=2.13.0-beta.3" },
13-
],
14-
GM_addElement: [
15-
{ type: "tampermonkey", versionConstraint: ">=4.11.6113" },
16-
{ type: "violentmonkey", versionConstraint: ">=2.13.0-beta.3" },
17-
{ type: "scriptcat", versionConstraint: "*" },
18-
],
19-
"GM.addStyle": [
20-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
21-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
22-
],
23-
GM_addStyle: [
24-
{ type: "tampermonkey", versionConstraint: "*" },
25-
{ type: "violentmonkey", versionConstraint: "*" },
26-
{ type: "greasemonkey", versionConstraint: ">=0.6.1.4 <4" },
27-
],
28-
"GM.addValueChangeListener": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
29-
GM_addValueChangeListener: [
30-
{ type: "tampermonkey", versionConstraint: ">=2.3.2607" },
31-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
32-
],
33-
"GM.cookie": [
34-
{ type: "tampermonkey", versionConstraint: ">=4.8" },
35-
{ type: "scriptcat", versionConstraint: "*" },
36-
],
37-
GM_cookie: [
38-
{ type: "tampermonkey", versionConstraint: ">=4.8" },
39-
{ type: "scriptcat", versionConstraint: "*" },
40-
],
41-
"GM.deleteValue": [
42-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
43-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
44-
{ type: "greasemonkey", versionConstraint: ">=4.0" },
45-
],
46-
GM_deleteValue: [
47-
{ type: "tampermonkey", versionConstraint: "*" },
48-
{ type: "violentmonkey", versionConstraint: "*" },
49-
{ type: "greasemonkey", versionConstraint: ">=0.8.20090123.1 <4" },
50-
],
51-
"GM.download": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
52-
GM_download: [
53-
{ type: "tampermonkey", versionConstraint: ">=3.8" },
54-
{ type: "violentmonkey", versionConstraint: ">=2.9.5" },
55-
],
56-
"GM.getResourceText": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
57-
GM_getResourceText: [
58-
{ type: "tampermonkey", versionConstraint: "*" },
59-
{ type: "violentmonkey", versionConstraint: "*" },
60-
{ type: "greasemonkey", versionConstraint: ">=0.8.20080609.0 <4" },
61-
],
62-
"GM.getResourceURL": [{ type: "violentmonkey", versionConstraint: ">=2.12.0 <2.13.0.10" }],
63-
GM_getResourceURL: [
64-
{ type: "tampermonkey", versionConstraint: "*" },
65-
{ type: "violentmonkey", versionConstraint: "*" },
66-
{ type: "greasemonkey", versionConstraint: ">=0.8.20080609.0 <4" },
67-
],
68-
"GM.getResourceUrl": [
69-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
70-
{ type: "violentmonkey", versionConstraint: ">=2.13.0.10" },
71-
{ type: "greasemonkey", versionConstraint: ">=4.0" },
72-
],
73-
"GM.getTab": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
74-
GM_getTab: [{ type: "tampermonkey", versionConstraint: ">=4.0.10" }],
75-
"GM.getTabs": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
76-
GM_getTabs: [{ type: "tampermonkey", versionConstraint: ">=4.0.10" }],
77-
"GM.getValue": [
78-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
79-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
80-
{ type: "greasemonkey", versionConstraint: ">=4.0" },
81-
],
82-
GM_getValue: [
83-
{ type: "tampermonkey", versionConstraint: "*" },
84-
{ type: "violentmonkey", versionConstraint: "*" },
85-
{ type: "greasemonkey", versionConstraint: ">=0.3-beta <4" },
86-
],
87-
"GM.info": [
88-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
89-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
90-
{ type: "greasemonkey", versionConstraint: ">=4" },
91-
],
92-
GM_info: [
93-
{ type: "tampermonkey", versionConstraint: ">=2.4.2718" },
94-
{ type: "violentmonkey", versionConstraint: "*" },
95-
{ type: "greasemonkey", versionConstraint: ">=0.9.16 <4" },
96-
],
97-
"GM.listValues": [
98-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
99-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
100-
{ type: "greasemonkey", versionConstraint: ">=4" },
101-
],
102-
GM_listValues: [
103-
{ type: "tampermonkey", versionConstraint: "*" },
104-
{ type: "violentmonkey", versionConstraint: "*" },
105-
{ type: "greasemonkey", versionConstraint: ">=0.8.20090123.1 <4" },
106-
],
107-
"GM.log": [
108-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
109-
{ type: "greasemonkey", versionConstraint: ">=4" },
110-
],
111-
GM_log: [
112-
{ type: "tampermonkey", versionConstraint: "*" },
113-
{ type: "violentmonkey", versionConstraint: "*" },
114-
{ type: "greasemonkey", versionConstraint: ">=0.3-beta <4" },
115-
],
116-
"GM.notification": [
117-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
118-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
119-
{ type: "greasemonkey", versionConstraint: ">=4" },
120-
],
121-
GM_notification: [
122-
{ type: "tampermonkey", versionConstraint: ">=2.0.2344" },
123-
{ type: "violentmonkey", versionConstraint: ">=2.5.0" },
124-
],
125-
"GM.openInTab": [
126-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
127-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
128-
{ type: "greasemonkey", versionConstraint: ">=4" },
129-
],
130-
GM_openInTab: [
131-
{ type: "tampermonkey", versionConstraint: "*" },
132-
{ type: "violentmonkey", versionConstraint: "*" },
133-
{ type: "greasemonkey", versionConstraint: ">=0.5-beta <4" },
134-
],
135-
"GM.registerMenuCommand": [
136-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
137-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
138-
{ type: "greasemonkey", versionConstraint: ">=4.11" },
139-
],
140-
GM_registerMenuCommand: [
141-
{ type: "tampermonkey", versionConstraint: "*" },
142-
{ type: "violentmonkey", versionConstraint: "*" },
143-
{ type: "greasemonkey", versionConstraint: ">=0.2.5 <4" },
144-
],
145-
"GM.removeValueChangeListener": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
146-
GM_removeValueChangeListener: [
147-
{ type: "tampermonkey", versionConstraint: ">=2.3.2607" },
148-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
149-
],
150-
"GM.saveTab": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
151-
GM_saveTab: [{ type: "tampermonkey", versionConstraint: ">=4.0.10" }],
152-
"GM.setClipboard": [
153-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
154-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
155-
{ type: "greasemonkey", versionConstraint: ">=4" },
156-
],
157-
GM_setClipboard: [
158-
{ type: "tampermonkey", versionConstraint: ">=2.6.2767" },
159-
{ type: "violentmonkey", versionConstraint: ">=2.5.0" },
160-
{ type: "greasemonkey", versionConstraint: ">=1.10 <4" },
161-
],
162-
"GM.setValue": [
163-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
164-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
165-
{ type: "greasemonkey", versionConstraint: ">=4" },
166-
],
167-
GM_setValue: [
168-
{ type: "tampermonkey", versionConstraint: "*" },
169-
{ type: "violentmonkey", versionConstraint: "*" },
170-
{ type: "greasemonkey", versionConstraint: ">=0.3-beta <4" },
171-
],
172-
"GM.unregisterMenuCommand": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
173-
GM_unregisterMenuCommand: [
174-
{ type: "tampermonkey", versionConstraint: ">=3.6.3737" },
175-
{ type: "violentmonkey", versionConstraint: ">=2.9.4" },
176-
],
177-
"GM.webRequest": [{ type: "tampermonkey", versionConstraint: ">=4.5" }],
178-
GM_webRequest: [{ type: "tampermonkey", versionConstraint: ">=4.4" }],
179-
GM_xmlhttpRequest: [
180-
{ type: "tampermonkey", versionConstraint: "*" },
181-
{ type: "violentmonkey", versionConstraint: "*" },
182-
{ type: "greasemonkey", versionConstraint: ">=0.2.5 <4" },
183-
],
184-
"GM.xmlHttpRequest": [
185-
{ type: "tampermonkey", versionConstraint: ">=4.5" },
186-
{ type: "violentmonkey", versionConstraint: ">=2.12.0" },
187-
{ type: "greasemonkey", versionConstraint: ">=4.0" },
188-
],
189-
none: [
190-
{ type: "tampermonkey", versionConstraint: "*" },
191-
{ type: "violentmonkey", versionConstraint: "*" },
192-
{ type: "greasemonkey", versionConstraint: "*" },
193-
],
194-
unsafeWindow: [
195-
{ type: "tampermonkey", versionConstraint: "*" },
196-
{ type: "violentmonkey", versionConstraint: "*" },
197-
{ type: "greasemonkey", versionConstraint: ">=0.5-beta" },
198-
],
199-
"window.close": [
200-
{ type: "tampermonkey", versionConstraint: ">=3.12.58" },
201-
{ type: "violentmonkey", versionConstraint: ">=2.6.2" },
202-
],
203-
"window.focus": [
204-
{ type: "tampermonkey", versionConstraint: ">=3.12.58" },
205-
{ type: "violentmonkey", versionConstraint: ">=2.12.10" },
206-
],
207-
"window.onurlchange": [{ type: "tampermonkey", versionConstraint: ">=4.11" }],
5+
...compat_grant.compatMap,
2086
};
2097

2108
const gmPolyfillOverride = {
211-
GM_addStyle: "ignore",
212-
GM_registerMenuCommand: "ignore",
213-
GM_getResourceText: {
214-
deps: ["GM.getResourceUrl", "GM.log"],
215-
},
216-
"GM.log": "ignore",
217-
"GM.info": {
218-
deps: ["GM_info"],
219-
},
220-
"GM.addStyle": {
221-
deps: ["GM_addStyle"],
222-
},
223-
"GM.deleteValue": {
224-
deps: ["GM_deleteValue"],
225-
},
226-
"GM.getResourceUrl": {
227-
deps: ["GM_getResourceURL"],
228-
},
229-
"GM.getValue": {
230-
deps: ["GM_getValue"],
231-
},
232-
"GM.listValues": {
233-
deps: ["GM_listValues"],
234-
},
235-
"GM.notification": {
236-
deps: ["GM_notification"],
237-
},
238-
"GM.openInTab": {
239-
deps: ["GM_openInTab"],
240-
},
241-
"GM.registerMenuCommand": {
242-
deps: ["GM_registerMenuCommand"],
243-
},
244-
"GM.setClipboard": {
245-
deps: ["GM_setClipboard"],
246-
},
247-
"GM.setValue": {
248-
deps: ["GM_setValue"],
249-
},
250-
"GM.xmlHttpRequest": {
251-
deps: ["GM_xmlhttpRequest"],
252-
},
253-
"GM.getResourceText": {
254-
deps: ["GM_getResourceText"],
255-
},
9+
...compat_grant.gmPolyfillOverride,
25610
};
25711

258-
module.exports.compatMap = compatMap;
259-
module.exports.gmPolyfillOverride = gmPolyfillOverride;
12+
module.exports = { compatMap, gmPolyfillOverride };

0 commit comments

Comments
 (0)