vite-userscript-plugin 1.10.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -82
- package/dist/index.d.ts +254 -180
- package/dist/index.js +902 -4
- package/package.json +55 -49
- package/types/greasemonkey.d.ts +277 -218
- package/types/tampermonkey.d.ts +1273 -658
- package/types/violentmonkey-ambient.d.ts +149 -0
- package/types/violentmonkey.d.ts +362 -154
- package/virtual.d.ts +7 -0
- package/dist/index.cjs +0 -5
- package/dist/index.d.cts +0 -187
- package/dist/ws.js +0 -1
- package/types/README.md +0 -21
package/package.json
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-userscript-plugin",
|
|
3
|
-
"version": "1.10.0",
|
|
4
3
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"require": "./dist/index.cjs",
|
|
10
|
-
"import": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"types"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"dev": "tsup --watch",
|
|
18
|
-
"build": "tsup",
|
|
19
|
-
"test": "vitest",
|
|
20
|
-
"test:ui": "vitest --ui --watch",
|
|
21
|
-
"dev:examples": "turbo run dev --filter='./examples/*'",
|
|
22
|
-
"build:examples": "turbo run build --filter='./examples/*'",
|
|
23
|
-
"format": "prettier --write --ignore-unknown **",
|
|
24
|
-
"prepublishOnly": "pnpm build"
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Vitalij Ryndin",
|
|
7
|
+
"url": "https://github.com/crashmax-dev"
|
|
25
8
|
},
|
|
9
|
+
"license": "MIT",
|
|
26
10
|
"repository": {
|
|
27
11
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/
|
|
12
|
+
"url": "git+https://github.com/greasify/vite-userscript-plugin.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/greasify/vite-userscript-plugin/issues"
|
|
29
16
|
},
|
|
30
17
|
"keywords": [
|
|
31
18
|
"vite",
|
|
@@ -35,37 +22,56 @@
|
|
|
35
22
|
"greasemonkey",
|
|
36
23
|
"violentmonkey"
|
|
37
24
|
],
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./dist/index.js",
|
|
27
|
+
"./virtual": "./virtual.d.ts",
|
|
28
|
+
"./types/tampermonkey": "./types/tampermonkey.d.ts",
|
|
29
|
+
"./types/greasemonkey": "./types/greasemonkey.d.ts",
|
|
30
|
+
"./types/violentmonkey": "./types/violentmonkey.d.ts"
|
|
42
31
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"types/*.d.ts",
|
|
36
|
+
"virtual.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"vite": "^8.0.0"
|
|
46
43
|
},
|
|
47
44
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"open": "9.1.0",
|
|
50
|
-
"picocolors": "1.0.0",
|
|
51
|
-
"serve-handler": "6.1.5",
|
|
52
|
-
"websocket": "1.0.34"
|
|
45
|
+
"open": "11.0.1"
|
|
53
46
|
},
|
|
54
47
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@types/node": "
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@vitest/ui": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
48
|
+
"@antfu/eslint-config": "7.2.0",
|
|
49
|
+
"@sveltejs/vite-plugin-svelte": "7.3.0",
|
|
50
|
+
"@types/node": "22.20.1",
|
|
51
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
52
|
+
"@vitejs/plugin-vue": "6.0.8",
|
|
53
|
+
"@vitest/ui": "4.1.11",
|
|
54
|
+
"eslint": "9.39.2",
|
|
55
|
+
"eslint-plugin-format": "2.0.1",
|
|
56
|
+
"prettier-plugin-css-order": "2.2.0",
|
|
57
|
+
"svelte": "5.56.10",
|
|
58
|
+
"tsdown": "0.22.14",
|
|
59
|
+
"turbo": "2.10.11",
|
|
60
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
61
|
+
"vite": "8.2.2",
|
|
62
|
+
"vitest": "4.1.11",
|
|
63
|
+
"vue": "3.5.41"
|
|
67
64
|
},
|
|
68
|
-
"
|
|
69
|
-
"
|
|
65
|
+
"scripts": {
|
|
66
|
+
"dev": "tsdown --watch",
|
|
67
|
+
"dev:examples": "turbo run dev --filter=./examples/*",
|
|
68
|
+
"build": "tsdown",
|
|
69
|
+
"build:examples": "turbo run build --filter=./examples/*",
|
|
70
|
+
"test": "vitest",
|
|
71
|
+
"test:ui": "vitest --ui --watch",
|
|
72
|
+
"type-check": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p scripts/tsconfig.json && turbo run type-check --filter=./examples/*",
|
|
73
|
+
"sync-types": "node scripts/sync-types.ts",
|
|
74
|
+
"lint": "eslint . --cache",
|
|
75
|
+
"lint:fix": "eslint . --fix --cache"
|
|
70
76
|
}
|
|
71
|
-
}
|
|
77
|
+
}
|
package/types/greasemonkey.d.ts
CHANGED
|
@@ -1,246 +1,305 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Definitions by: Kota Saito <https://github.com/kotas>
|
|
4
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
1
|
+
// synced from @types/greasemonkey@4.0.7
|
|
2
|
+
// do not edit; run pnpm sync-types
|
|
5
3
|
|
|
6
|
-
// This definition is based on the API reference of Greasemonkey
|
|
7
|
-
//
|
|
4
|
+
// This definition is based on the API reference of Greasemonkey
|
|
5
|
+
// https://wiki.greasespot.net/Greasemonkey_Manual:API
|
|
6
|
+
// TypeScript Version: 3.2
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
declare namespace GM {
|
|
9
|
+
interface ScriptInfo {
|
|
10
|
+
/** Possibly empty string. */
|
|
11
|
+
description: string;
|
|
12
|
+
excludes: string[];
|
|
13
|
+
includes: string[];
|
|
14
|
+
matches: string[];
|
|
15
|
+
name: string;
|
|
16
|
+
/** Possibly empty string. */
|
|
17
|
+
namespace: string;
|
|
18
|
+
/**
|
|
19
|
+
* An object keyed by resource name.
|
|
20
|
+
* Each value is an object with keys `name` and `mimetype` and `url`
|
|
21
|
+
* with string values.
|
|
22
|
+
*/
|
|
23
|
+
resources: {
|
|
24
|
+
[resourceName: string]: {
|
|
25
|
+
name: string;
|
|
26
|
+
mimetype: string;
|
|
27
|
+
url: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/** @default 'end' */
|
|
31
|
+
runAt: "start" | "end" | "idle";
|
|
32
|
+
uuid: string;
|
|
33
|
+
/** Possibly empty string. */
|
|
34
|
+
version: string;
|
|
35
|
+
}
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
* Window object of the content page where the user script is running on.
|
|
15
|
-
* @see {@link http://wiki.greasespot.net/UnsafeWindow}
|
|
16
|
-
*/
|
|
17
|
-
declare var unsafeWindow: Window
|
|
37
|
+
type Value = string | boolean | number;
|
|
18
38
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
script: {
|
|
25
|
-
description: string
|
|
26
|
-
excludes: string[]
|
|
27
|
-
includes: string[]
|
|
28
|
-
matches: string[]
|
|
29
|
-
name: string
|
|
30
|
-
namespace: string
|
|
31
|
-
resources: Object
|
|
32
|
-
'run-at': string
|
|
33
|
-
unwrap: boolean
|
|
34
|
-
version: string
|
|
35
|
-
}
|
|
36
|
-
scriptMetaStr: string
|
|
37
|
-
scriptWillUpdate: boolean
|
|
38
|
-
version: string
|
|
39
|
-
}
|
|
39
|
+
interface Response<TContext> {
|
|
40
|
+
readonly responseHeaders: string;
|
|
41
|
+
readonly finalUrl: string;
|
|
42
|
+
/** The same object passed into the original request */
|
|
43
|
+
readonly context?: TContext | undefined;
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
readonly readyState: 1 | 2 | 3 | 4;
|
|
46
|
+
readonly response: any;
|
|
47
|
+
readonly responseText: string;
|
|
48
|
+
readonly responseXML: Document | false;
|
|
49
|
+
readonly status: number;
|
|
50
|
+
readonly statusText: string;
|
|
51
|
+
}
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
declare function GM_deleteValue(name: string): void
|
|
53
|
+
interface ProgressResponse<TContext> extends Response<TContext> {
|
|
54
|
+
lengthComputable: boolean;
|
|
55
|
+
loaded: number;
|
|
56
|
+
total: number;
|
|
57
|
+
}
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @param name a name to retrieve.
|
|
55
|
-
* @param defaultValue a value to be returned when the name does not exist.
|
|
56
|
-
* @returns a retrieved value, or passed default value, or undefined.
|
|
57
|
-
* @see {@link http://wiki.greasespot.net/GM_getValue}
|
|
58
|
-
*/
|
|
59
|
-
declare function GM_getValue(name: string, defaultValue?: any): any
|
|
60
|
-
declare function GM_getValue(name: string, defaultValue?: string): string
|
|
61
|
-
declare function GM_getValue(name: string, defaultValue?: number): number
|
|
62
|
-
declare function GM_getValue(name: string, defaultValue?: boolean): boolean
|
|
59
|
+
interface Request<TContext = any> {
|
|
60
|
+
// Fields
|
|
63
61
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
/**
|
|
63
|
+
* The URL to make the request to. Must be an absolute URL, beginning
|
|
64
|
+
* with the scheme. May be relative to the current page.
|
|
65
|
+
*/
|
|
66
|
+
url: string;
|
|
67
|
+
/** String type of HTTP request to make (E.G. "GET", "POST") */
|
|
68
|
+
method:
|
|
69
|
+
| "GET"
|
|
70
|
+
| "POST"
|
|
71
|
+
| "PUT"
|
|
72
|
+
| "DELETE"
|
|
73
|
+
| "PATCH"
|
|
74
|
+
| "HEAD"
|
|
75
|
+
| "TRACE"
|
|
76
|
+
| "OPTIONS"
|
|
77
|
+
| "CONNECT";
|
|
78
|
+
/**
|
|
79
|
+
* When true, the data is sent as a Blob
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
binary?: boolean | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Any object (Compatibility: 1.10+). This object will also be the
|
|
85
|
+
* context property of the Response Object.
|
|
86
|
+
*/
|
|
87
|
+
context?: TContext | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Data to send in the request body. Usually for POST method requests.
|
|
90
|
+
* If the data field contains form-encoded data, you usually must also
|
|
91
|
+
* set the header `'Content-Type': 'application/x-www-form-urlencoded'`
|
|
92
|
+
* in the `headers` field.
|
|
93
|
+
*/
|
|
94
|
+
data?: string | undefined;
|
|
95
|
+
/** A set of headers to include in the request */
|
|
96
|
+
headers?: {
|
|
97
|
+
[header: string]: string;
|
|
98
|
+
} | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* A MIME type to specify with the request (e.g.
|
|
101
|
+
* "text/html; charset=ISO-8859-1")
|
|
102
|
+
*/
|
|
103
|
+
overrideMimeType?: string | undefined;
|
|
104
|
+
/** User name to use for authentication purposes. */
|
|
105
|
+
user?: string | undefined;
|
|
106
|
+
/** Password to use for authentication purposes */
|
|
107
|
+
password?: string | undefined;
|
|
108
|
+
/** Decode the response as specified type. Default value is "text" */
|
|
109
|
+
responseType?: XMLHttpRequestResponseType | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* When `true`, this is a synchronous request.
|
|
112
|
+
* Be careful: The entire Firefox UI will be locked and frozen until the
|
|
113
|
+
* request completes.In this mode, more data will be available in the
|
|
114
|
+
* return value.
|
|
115
|
+
*/
|
|
116
|
+
synchronous?: boolean | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* The number of milliseconds to wait before terminating the call. Zero
|
|
119
|
+
* (the default) means wait forever.
|
|
120
|
+
*/
|
|
121
|
+
timeout?: number | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Object containing optional function callbacks to monitor the upload
|
|
124
|
+
* of data.
|
|
125
|
+
*/
|
|
126
|
+
upload?: {
|
|
127
|
+
onabort?(response: Response<TContext>): void;
|
|
128
|
+
onerror?(response: Response<TContext>): void;
|
|
129
|
+
onload?(response: Response<TContext>): void;
|
|
130
|
+
onprogress?(response: ProgressResponse<TContext>): void;
|
|
131
|
+
} | undefined;
|
|
70
132
|
|
|
71
|
-
|
|
72
|
-
* Stores a name / value pair to the script storage.
|
|
73
|
-
* @param name a name of the pair.
|
|
74
|
-
* @param value a value to be stored.
|
|
75
|
-
* @see {@link http://wiki.greasespot.net/GM_setValue}
|
|
76
|
-
*/
|
|
77
|
-
declare function GM_setValue(name: string, value: string): void
|
|
78
|
-
declare function GM_setValue(name: string, value: boolean): void
|
|
79
|
-
declare function GM_setValue(name: string, value: number): void
|
|
133
|
+
// Event handlers
|
|
80
134
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
135
|
+
/** Will be called when the request is aborted */
|
|
136
|
+
onabort?(response: Response<TContext>): void;
|
|
137
|
+
/** Will be called if an error occurs while processing the request */
|
|
138
|
+
onerror?(response: Response<TContext>): void;
|
|
139
|
+
/** Will be called when the request has completed successfully */
|
|
140
|
+
onload?(response: Response<TContext>): void;
|
|
141
|
+
/** Will be called when the request progress changes */
|
|
142
|
+
onprogress?(response: ProgressResponse<TContext>): void;
|
|
143
|
+
/** Will be called repeatedly while the request is in progress */
|
|
144
|
+
onreadystatechange?(response: Response<TContext>): void;
|
|
145
|
+
/** Will be called if/when the request times out */
|
|
146
|
+
ontimeout?(response: Response<TContext>): void;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
84
149
|
|
|
85
150
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
* @returns the content of the resource.
|
|
89
|
-
* @see {@link http://wiki.greasespot.net/GM_getResourceText}
|
|
151
|
+
* Window object of the content page where the user script is running on.
|
|
152
|
+
* @see {@link http://wiki.greasespot.net/UnsafeWindow}
|
|
90
153
|
*/
|
|
91
|
-
declare
|
|
154
|
+
declare var unsafeWindow: Window;
|
|
92
155
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* @param resourceName a name of the resource.
|
|
96
|
-
* @returns a URL that returns the content of the resource.
|
|
97
|
-
* @see {@link http://wiki.greasespot.net/GM_getResourceURL}
|
|
98
|
-
*/
|
|
99
|
-
declare function GM_getResourceURL(resourceName: string): string
|
|
156
|
+
declare var GM: {
|
|
157
|
+
// Headers
|
|
100
158
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Meta data about the running user script.
|
|
161
|
+
* @see {@link https://wiki.greasespot.net/GM.info}
|
|
162
|
+
*/
|
|
163
|
+
info: {
|
|
164
|
+
/** An object containing data about the currently running script */
|
|
165
|
+
script: GM.ScriptInfo;
|
|
166
|
+
/**
|
|
167
|
+
* A string, the entire literal Metadata Block (without the delimiters)
|
|
168
|
+
* for the currently running script
|
|
169
|
+
*/
|
|
170
|
+
scriptMetaStr: string;
|
|
171
|
+
/**
|
|
172
|
+
* The name of the user script engine handling this script's execution.
|
|
173
|
+
* The string `Greasemonkey`
|
|
174
|
+
*/
|
|
175
|
+
scriptHandler: string;
|
|
176
|
+
/** The version of Greasemonkey, a string e.g. `4.0` */
|
|
177
|
+
version: string;
|
|
178
|
+
};
|
|
104
179
|
|
|
105
|
-
|
|
106
|
-
* Adds CSS to the content page.
|
|
107
|
-
* @param css a CSS string. It can have multiple style definitions.
|
|
108
|
-
* @see {@link http://wiki.greasespot.net/GM_addStyle}
|
|
109
|
-
*/
|
|
110
|
-
declare function GM_addStyle(css: string): void
|
|
180
|
+
// Values
|
|
111
181
|
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Allows user script authors to persist simple values across page loads and
|
|
184
|
+
* across origins.
|
|
185
|
+
* Strings, booleans, and integers are currently the only allowed data types.
|
|
186
|
+
* @see {@link https://wiki.greasespot.net/GM.setValue}
|
|
187
|
+
* @param name The unique (within this script) name for this value.
|
|
188
|
+
* Should be restricted to valid Javascript identifier characters.
|
|
189
|
+
* @param value Any valid value of these types. Any other type may cause
|
|
190
|
+
* undefined behavior, including crashes
|
|
191
|
+
* @returns A Promise, resolved successfully with no value on success,
|
|
192
|
+
* rejected with no value on failure
|
|
193
|
+
*/
|
|
194
|
+
setValue(name: string, value: GM.Value): Promise<void>;
|
|
118
195
|
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Retrieves a value that was set with `GM.setValue`
|
|
198
|
+
* @see {@link https://wiki.greasespot.net/GM.getValue}
|
|
199
|
+
* @param name The property name to get
|
|
200
|
+
* @param defaultValue The default value to be returned when none has
|
|
201
|
+
* previously been set
|
|
202
|
+
* @returns A Promise, rejected in case of error and otherwise resolved with:
|
|
203
|
+
* - When this name has been set - `string`, `integer` or `boolean` as
|
|
204
|
+
* previously set
|
|
205
|
+
* - When this name has not been set, and default is provided - The value
|
|
206
|
+
* passed as default
|
|
207
|
+
* - When this name has not been set, and default is not provided -
|
|
208
|
+
* `undefined`
|
|
209
|
+
* @example
|
|
210
|
+
* // Retrieving the value associated with the name 'timezoneOffset' with a default value defined:
|
|
211
|
+
* const timezoneOffset = await GM.getValue("timezoneOffset", -5)
|
|
212
|
+
* @example
|
|
213
|
+
* // For structured data used `JSON.stringify()` to place an object into storage and then `JSON.parse()` to convert it back
|
|
214
|
+
* const storedObject = JSON.parse(await GM.getValue('foo', '{}'));
|
|
215
|
+
*/
|
|
216
|
+
getValue(
|
|
217
|
+
name: string,
|
|
218
|
+
): Promise<GM.Value | undefined>;
|
|
219
|
+
getValue<TValue = GM.Value>(
|
|
220
|
+
name: string,
|
|
221
|
+
defaultValue: TValue,
|
|
222
|
+
): Promise<TValue>;
|
|
126
223
|
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
declare function GM_registerMenuCommand(
|
|
136
|
-
caption: string,
|
|
137
|
-
commandFunc: Function,
|
|
138
|
-
accessKey?: string
|
|
139
|
-
): void
|
|
224
|
+
/**
|
|
225
|
+
* Deletes an existing name / value pair from storage.
|
|
226
|
+
* @see {@link https://wiki.greasespot.net/GM.deleteValue}
|
|
227
|
+
* @param name Property name to delete
|
|
228
|
+
* @returns A Promise, resolved successfully with no value on success,
|
|
229
|
+
* rejected with no value on failure.
|
|
230
|
+
*/
|
|
231
|
+
deleteValue(name: string): Promise<void>;
|
|
140
232
|
|
|
141
|
-
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Retrieves an array of preference names that this script has stored
|
|
235
|
+
* @see {@link https://wiki.greasespot.net/GM.listValues}
|
|
236
|
+
* @returns A Promise, rejected in case of error and otherwise resolved with
|
|
237
|
+
* an string[] for previously set values
|
|
238
|
+
*/
|
|
239
|
+
listValues(): Promise<string[]>;
|
|
147
240
|
|
|
148
|
-
|
|
149
|
-
// XMLHttpRequest
|
|
150
|
-
////////////////
|
|
241
|
+
// Resources
|
|
151
242
|
|
|
152
|
-
/**
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
onabort?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
163
|
-
onerror?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
164
|
-
onload?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
165
|
-
onprogress?: ((response: GMXMLHttpRequestProgressResponse) => any) | undefined
|
|
166
|
-
onreadystatechange?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
167
|
-
ontimeout?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
168
|
-
overrideMimeType?: string | undefined
|
|
169
|
-
password?: string | undefined
|
|
170
|
-
synchronous?: boolean | undefined
|
|
171
|
-
timeout?: number | undefined
|
|
172
|
-
upload?:
|
|
173
|
-
| {
|
|
174
|
-
onabort?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
175
|
-
onerror?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
176
|
-
onload?: ((response: GMXMLHttpRequestResponse) => any) | undefined
|
|
177
|
-
onprogress?:
|
|
178
|
-
| ((response: GMXMLHttpRequestProgressResponse) => any)
|
|
179
|
-
| undefined
|
|
180
|
-
}
|
|
181
|
-
| undefined
|
|
182
|
-
url: string
|
|
183
|
-
user?: string | undefined
|
|
184
|
-
}
|
|
243
|
+
/**
|
|
244
|
+
* Given a defined `@resource`, this method returns it as a URL
|
|
245
|
+
* @see {@link https://wiki.greasespot.net/GM.getResourceUrl}
|
|
246
|
+
* @param resourceName The name provided when the `@resource` was defined
|
|
247
|
+
* @returns A Promise, rejected on failure and resolved with a string URL on
|
|
248
|
+
* success.
|
|
249
|
+
* Treat the result as opaque string. It will work where you need a URL
|
|
250
|
+
* (for a `<link>` or `<style>` for CSS, for an `<img>` tag, or similar).
|
|
251
|
+
*/
|
|
252
|
+
getResourceUrl(resourceName: string): Promise<string>;
|
|
185
253
|
|
|
186
|
-
|
|
187
|
-
* Response object for general events of {@link GM_xmlhttpRequest}.
|
|
188
|
-
* @see {@link http://wiki.greasespot.net/GM_xmlhttpRequest#Response_Object}
|
|
189
|
-
*/
|
|
190
|
-
interface GMXMLHttpRequestResponse {
|
|
191
|
-
readyState: number
|
|
192
|
-
responseHeaders: string
|
|
193
|
-
responseText: string
|
|
194
|
-
status: number
|
|
195
|
-
statusText: string
|
|
196
|
-
context: any
|
|
197
|
-
finalUrl: string
|
|
198
|
-
}
|
|
254
|
+
// Other
|
|
199
255
|
|
|
200
|
-
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Displays a notification to the user, using the underlying operating
|
|
258
|
+
* system's notification mechanism
|
|
259
|
+
* @see {@link https://wiki.greasespot.net/GM.notification}
|
|
260
|
+
* @param text The main notification text
|
|
261
|
+
* @param title The title of the notification
|
|
262
|
+
* @param image The URL for an image to display in the dialog. If not
|
|
263
|
+
* provided, the Greasemonkey logo by default.
|
|
264
|
+
* @param onClick Callback, triggered when the notification's button is
|
|
265
|
+
* clicked.
|
|
266
|
+
*/
|
|
267
|
+
notification(
|
|
268
|
+
text: string,
|
|
269
|
+
title: string,
|
|
270
|
+
image?: string,
|
|
271
|
+
onClick?: () => void,
|
|
272
|
+
): void;
|
|
208
273
|
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
274
|
+
/**
|
|
275
|
+
* Opens the specified URL in a new tab.
|
|
276
|
+
* @see {@link https://wiki.greasespot.net/GM.openInTab}
|
|
277
|
+
* @param url The URL to navigate the new tab to
|
|
278
|
+
* @param openInBackground Force tab to/to not open in a background tab.
|
|
279
|
+
* Default (unspecified) behavior honors Firefox configuration.
|
|
280
|
+
*/
|
|
281
|
+
openInTab(url: string, openInBackground?: boolean): void;
|
|
215
282
|
|
|
216
|
-
/**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
status: number
|
|
226
|
-
statusText: string
|
|
227
|
-
}
|
|
283
|
+
/**
|
|
284
|
+
* Adds an item to the User Script Commands menu.
|
|
285
|
+
* @param caption The caption to display on the menu item.
|
|
286
|
+
* @param commandFunc The function to call when the menu item is selected.
|
|
287
|
+
* @param accessKey A single character that can be used to select the
|
|
288
|
+
* item when the menu is open. It should be a letter in the caption.
|
|
289
|
+
* @see {@link https://wiki.greasespot.net/GM.registerMenuCommand}
|
|
290
|
+
*/
|
|
291
|
+
registerMenuCommand(caption: string, commandFunc: () => void, accessKey?: string): void;
|
|
228
292
|
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
extends GMXMLHttpRequestAsyncResult,
|
|
235
|
-
GMXMLHttpRequestSyncResult {}
|
|
293
|
+
/**
|
|
294
|
+
* Sets the current contents of the operating system's clipboard
|
|
295
|
+
* @see {@link https://wiki.greasespot.net/GM.setClipboard}
|
|
296
|
+
*/
|
|
297
|
+
setClipboard(text: string): void;
|
|
236
298
|
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
declare function GM_xmlhttpRequest(
|
|
245
|
-
options: GMXMLHttpRequestOptions
|
|
246
|
-
): GMXMLHttpRequestResult
|
|
299
|
+
/**
|
|
300
|
+
* Performs a similar function to the standard XMLHttpRequest object, but
|
|
301
|
+
* allows these requests to cross the [same origin policy]{@link https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy} boundaries.
|
|
302
|
+
* @see {@link https://wiki.greasespot.net/GM.xmlHttpRequest}
|
|
303
|
+
*/
|
|
304
|
+
xmlHttpRequest(details: GM.Request): void;
|
|
305
|
+
};
|