vite-userscript-plugin 1.11.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 +152 -98
- package/dist/index.d.ts +254 -180
- package/dist/index.js +890 -282
- package/package.json +51 -44
- package/types/greasemonkey.d.ts +267 -270
- package/types/tampermonkey.d.ts +1096 -954
- package/types/violentmonkey-ambient.d.ts +149 -0
- package/types/violentmonkey.d.ts +319 -186
- package/virtual.d.ts +7 -0
- package/dist/ws.js +0 -14
- package/types/README.md +0 -21
package/types/tampermonkey.d.ts
CHANGED
|
@@ -1,684 +1,750 @@
|
|
|
1
|
+
// synced from @types/tampermonkey@5.5.0
|
|
2
|
+
// do not edit; run pnpm sync-types
|
|
3
|
+
|
|
1
4
|
// This definition is based on the API reference of Tampermonkey
|
|
2
5
|
// https://tampermonkey.net/documentation.php
|
|
3
6
|
// TypeScript Version: 3.3
|
|
4
7
|
|
|
5
8
|
declare namespace Tampermonkey {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @param oldValue The previous value of the key.
|
|
9
|
-
* @param newValue The new value of the key
|
|
10
|
-
* @param remote A boolean indicating whether the change originated from a different userscript instance.
|
|
11
|
-
*/
|
|
12
|
-
type ValueChangeListener = (
|
|
13
|
-
name: string,
|
|
14
|
-
oldValue: any,
|
|
15
|
-
newValue: any,
|
|
16
|
-
remote: boolean
|
|
17
|
-
) => void
|
|
18
|
-
|
|
19
|
-
// Response
|
|
20
|
-
|
|
21
|
-
enum ReadyState {
|
|
22
|
-
Unsent = 0,
|
|
23
|
-
Opened = 1,
|
|
24
|
-
HeadersReceived = 2,
|
|
25
|
-
Loading = 3,
|
|
26
|
-
Done = 4
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface ResponseBase {
|
|
30
|
-
readonly responseHeaders: string
|
|
31
|
-
/** The request's `readyState`. */
|
|
32
|
-
readonly readyState: ReadyState
|
|
33
|
-
/** The response data as object if `details.responseType` was set. */
|
|
34
|
-
readonly response: any
|
|
35
|
-
/** The response data as plain string. */
|
|
36
|
-
readonly responseText: string
|
|
37
|
-
/** The response data as an XML document. */
|
|
38
|
-
readonly responseXML: Document | null
|
|
39
|
-
readonly status: number
|
|
40
|
-
readonly statusText: string
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface ProgressResponseBase {
|
|
44
|
-
done: number
|
|
45
|
-
lengthComputable: boolean
|
|
46
|
-
loaded: number
|
|
47
|
-
position: number
|
|
48
|
-
total: number
|
|
49
|
-
totalSize: number
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface ErrorResponse extends ResponseBase {
|
|
53
|
-
readonly error: string
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface Response<TContext> extends ResponseBase {
|
|
57
|
-
/** The final URL after all redirects from where the data was loaded. */
|
|
58
|
-
readonly finalUrl: string
|
|
59
|
-
readonly context: TContext
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface ProgressResponse<TContext>
|
|
63
|
-
extends Response<TContext>,
|
|
64
|
-
ProgressResponseBase {}
|
|
65
|
-
|
|
66
|
-
// Request
|
|
67
|
-
|
|
68
|
-
interface RequestHeaders {
|
|
69
|
-
readonly [header: string]: string
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type RequestEventListener<TResponse> = (
|
|
73
|
-
this: TResponse,
|
|
74
|
-
response: TResponse
|
|
75
|
-
) => void
|
|
76
|
-
|
|
77
|
-
interface Request<TContext = object> {
|
|
78
|
-
method?: 'GET' | 'HEAD' | 'POST'
|
|
79
|
-
/** The destination URL */
|
|
80
|
-
url: string | URL
|
|
9
|
+
type StorageValue = object | string | number | boolean | undefined | null;
|
|
10
|
+
|
|
81
11
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
12
|
+
* @param key The key whose value has changed.
|
|
13
|
+
* @param oldValue The previous value of the key.
|
|
14
|
+
* @param newValue The new value of the key
|
|
15
|
+
* @param remote A boolean indicating whether the change originated from a different userscript instance.
|
|
84
16
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
17
|
+
type ValueChangeListener = {
|
|
18
|
+
bivarianceHack(name: string, oldValue: StorageValue, newValue: StorageValue, remote: boolean): void;
|
|
19
|
+
}["bivarianceHack"];
|
|
20
|
+
|
|
21
|
+
// Response
|
|
22
|
+
|
|
23
|
+
enum ReadyState {
|
|
24
|
+
Unsent = 0,
|
|
25
|
+
Opened = 1,
|
|
26
|
+
HeadersReceived = 2,
|
|
27
|
+
Loading = 3,
|
|
28
|
+
Done = 4,
|
|
96
29
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
30
|
+
|
|
31
|
+
interface ResponseBase {
|
|
32
|
+
readonly responseHeaders: string;
|
|
33
|
+
/** The request's `readyState`. */
|
|
34
|
+
readonly readyState: ReadyState;
|
|
35
|
+
/** The response data as object if `details.responseType` was set. */
|
|
36
|
+
readonly response: any;
|
|
37
|
+
/** The response data as plain string. */
|
|
38
|
+
readonly responseText: string;
|
|
39
|
+
/** The response data as an XML document. */
|
|
40
|
+
readonly responseXML: Document | null;
|
|
41
|
+
readonly status: number;
|
|
42
|
+
readonly statusText: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ProgressResponseBase {
|
|
46
|
+
done: number;
|
|
47
|
+
lengthComputable: boolean;
|
|
48
|
+
loaded: number;
|
|
49
|
+
position: number;
|
|
50
|
+
total: number;
|
|
51
|
+
totalSize: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface ErrorResponse extends ResponseBase {
|
|
55
|
+
readonly error: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface Response<TContext> extends ResponseBase {
|
|
59
|
+
/** The final URL after all redirects from where the data was loaded. */
|
|
60
|
+
readonly finalUrl: string;
|
|
61
|
+
readonly context: TContext;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface ProgressResponse<TContext> extends Response<TContext>, ProgressResponseBase {}
|
|
65
|
+
|
|
66
|
+
// Request
|
|
67
|
+
|
|
68
|
+
interface RequestHeaders {
|
|
69
|
+
readonly [header: string]: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type RequestEventListener<TResponse> = (this: TResponse, response: TResponse) => void;
|
|
73
|
+
|
|
74
|
+
interface Request<TContext = object> {
|
|
75
|
+
method?: "GET" | "HEAD" | "POST" | "PUT" | "DELETE";
|
|
76
|
+
/** The destination URL, or a Blob or File object (since v5.4.6226) */
|
|
77
|
+
url: string | URL | File | Blob;
|
|
78
|
+
/**
|
|
79
|
+
* i.e. user-agent, referer... (some special headers are not supported
|
|
80
|
+
* by Safari and Android browsers)
|
|
81
|
+
*/
|
|
82
|
+
headers?: RequestHeaders;
|
|
83
|
+
/** Data to send via a POST or PUT request */
|
|
84
|
+
data?: string | Blob | File | object | any[] | FormData | URLSearchParams;
|
|
85
|
+
/** Controls what to happen when a redirect is detected (build 6180+, enforces fetch mode). */
|
|
86
|
+
redirect?: "follow" | "error" | "manual";
|
|
87
|
+
/** A cookie to be patched into the sent cookie set */
|
|
88
|
+
cookie?: string;
|
|
89
|
+
/** Object containing the partition key to be used for sent and received partitioned cookies */
|
|
90
|
+
cookiePartition?: {
|
|
91
|
+
/** String representing the top frame site for partitioned cookies */
|
|
92
|
+
topLevelSite?: string;
|
|
93
|
+
};
|
|
94
|
+
/** Send the data string in binary mode */
|
|
95
|
+
binary?: boolean;
|
|
96
|
+
/** Don't cache the resource */
|
|
97
|
+
nocache?: boolean;
|
|
98
|
+
/** Revalidate maybe cached content */
|
|
99
|
+
revalidate?: boolean;
|
|
100
|
+
/** Timeout in ms */
|
|
101
|
+
timeout?: number;
|
|
102
|
+
/** Property which will be added to the response object */
|
|
103
|
+
context?: TContext;
|
|
104
|
+
responseType?: "arraybuffer" | "blob" | "json" | "stream";
|
|
105
|
+
/** MIME type for the request */
|
|
106
|
+
overrideMimeType?: string;
|
|
107
|
+
/** Don't send cookies with the requests (enforces `fetch` mode) */
|
|
108
|
+
anonymous?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* (Beta) Use a fetch instead of a xhr request (at Chrome this causes
|
|
111
|
+
* `xhr.abort`, `details.timeout` and `xhr.onprogress` to not work and
|
|
112
|
+
* makes `xhr.onreadystatechange` receive only readyState 4 events)
|
|
113
|
+
*/
|
|
114
|
+
fetch?: boolean;
|
|
115
|
+
/** Explicit proxy configuration. Available since v5.5.6233 and is only applicable in Firefox. */
|
|
116
|
+
proxy?: {
|
|
117
|
+
/** The kind of proxy to use (e.g. `direct`, `http`, `https`, `socks`, `socks4`) */
|
|
118
|
+
type: string;
|
|
119
|
+
/** The hostname of the proxy server */
|
|
120
|
+
host: string;
|
|
121
|
+
/** The port number of the proxy server */
|
|
122
|
+
port: number;
|
|
123
|
+
/** Username for SOCKS proxies */
|
|
124
|
+
username?: string;
|
|
125
|
+
/** Password for SOCKS proxies */
|
|
126
|
+
password?: string;
|
|
127
|
+
/** Use the proxy for DNS resolution (only for `socks`/`socks4`) */
|
|
128
|
+
proxyDNS?: boolean;
|
|
129
|
+
/** Fail‑over timeout in seconds */
|
|
130
|
+
failoverTimeout?: number;
|
|
131
|
+
/** Value sent as Proxy-Authorization for HTTP/HTTPS proxies */
|
|
132
|
+
proxyAuthorizationHeader?: string;
|
|
133
|
+
/** Additional key for connection isolation */
|
|
134
|
+
connectionIsolationKey?: string;
|
|
135
|
+
};
|
|
136
|
+
/** Username for authentication */
|
|
137
|
+
user?: string;
|
|
138
|
+
/** Password for authentication */
|
|
139
|
+
password?: string;
|
|
140
|
+
|
|
141
|
+
// Events
|
|
142
|
+
|
|
143
|
+
/** Callback to be executed if the request was aborted */
|
|
144
|
+
onabort?(): void;
|
|
145
|
+
/** Callback to be executed if the request ended up with an error */
|
|
146
|
+
onerror?: RequestEventListener<ErrorResponse>;
|
|
147
|
+
/** Callback to be executed if the request started to load */
|
|
148
|
+
onloadstart?: RequestEventListener<Response<TContext>>;
|
|
149
|
+
/** Callback to be executed if the request made some progress */
|
|
150
|
+
onprogress?: RequestEventListener<ProgressResponse<TContext>>;
|
|
151
|
+
/** Callback to be executed if the request's ready state changed */
|
|
152
|
+
onreadystatechange?: RequestEventListener<Response<TContext>>;
|
|
153
|
+
/** Callback to be executed if the request failed due to a timeout */
|
|
154
|
+
ontimeout?(): void;
|
|
155
|
+
/** Callback to be executed if the request was loaded */
|
|
156
|
+
onload?: RequestEventListener<Response<TContext>>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Download Response
|
|
160
|
+
|
|
161
|
+
interface DownloadProgressResponse extends ProgressResponseBase {
|
|
162
|
+
readonly finalUrl: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface DownloadErrorResponse {
|
|
166
|
+
/**
|
|
167
|
+
* Error reason
|
|
168
|
+
* - `not_enabled` - the download feature isn't enabled by the user
|
|
169
|
+
* - `not_whitelisted` - the requested file extension is not
|
|
170
|
+
* whitelisted
|
|
171
|
+
* - `not_permitted` - the user enabled the download feature, but did
|
|
172
|
+
* not give the *downloads* permission
|
|
173
|
+
* - `not_supported` - the download feature isn't supported by the
|
|
174
|
+
* browser/version
|
|
175
|
+
* - `not_succeeded` - the download wasn't started or failed, the
|
|
176
|
+
* *details* attribute may provide more information
|
|
177
|
+
*/
|
|
178
|
+
error: "not_enabled" | "not_whitelisted" | "not_permitted" | "not_supported" | "not_succeeded";
|
|
179
|
+
/** Detail about that error */
|
|
180
|
+
details?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Download Request
|
|
184
|
+
|
|
185
|
+
interface DownloadRequest {
|
|
186
|
+
/**
|
|
187
|
+
* The URL of the file to download or a `Blob` or `File` object (v5.4.6226+). In case of a
|
|
188
|
+
* string, this must be a valid URL and must point to a file that is accessible to the user.
|
|
189
|
+
*/
|
|
190
|
+
url: string | Blob | File;
|
|
191
|
+
/**
|
|
192
|
+
* The name to use for the downloaded file. This should include the file's extension,
|
|
193
|
+
* such as `.txt` or `.pdf`. For security reasons the file extension needs to be
|
|
194
|
+
* whitelisted at Tampermonkey's options page.
|
|
195
|
+
*/
|
|
196
|
+
name: string;
|
|
197
|
+
/**
|
|
198
|
+
* An object containing HTTP headers to include in the download request.
|
|
199
|
+
* See `GM_xmlhttpRequest` for more details.
|
|
200
|
+
*/
|
|
201
|
+
headers?: RequestHeaders;
|
|
202
|
+
/**
|
|
203
|
+
* A boolean value indicating whether to use the user's default download location,
|
|
204
|
+
* or to prompt the user to choose a different location.
|
|
205
|
+
* This option works in browser API mode only.
|
|
206
|
+
*/
|
|
207
|
+
saveAs?: boolean;
|
|
208
|
+
timeout?: number;
|
|
209
|
+
/**
|
|
210
|
+
* A string that control what happens when a file with this name already exists.
|
|
211
|
+
* This option works in browser API mode only. Please check
|
|
212
|
+
* [this link](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/FilenameConflictAction)
|
|
213
|
+
* for more details.
|
|
214
|
+
*/
|
|
215
|
+
conflictAction?: "uniquify" | "overwrite" | "prompt";
|
|
216
|
+
/** A function to call if the download fails or is cancelled. */
|
|
217
|
+
onerror?: RequestEventListener<DownloadErrorResponse>;
|
|
218
|
+
/** A callback to be executed if this download failed due to a timeout. */
|
|
219
|
+
ontimeout?(): void;
|
|
220
|
+
/** A function to call when the download has completed successfully. */
|
|
221
|
+
onload?(): void;
|
|
222
|
+
/** Callback to be executed if this download failed due to a timeout */
|
|
223
|
+
onprogress?: RequestEventListener<DownloadProgressResponse>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface AbortHandle<TReturn> {
|
|
227
|
+
/** A function which can be called to cancel this action. */
|
|
228
|
+
abort(): TReturn;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
type PromiseWithAbort<T> = Promise<T> & AbortHandle<void>;
|
|
232
|
+
|
|
233
|
+
interface OpenTabOptions {
|
|
234
|
+
/** A boolean value indicating whether the new tab should be active (selected) or not (default is `false`). */
|
|
235
|
+
active?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* An integer indicating the position at which the new tab should be inserted in the tab strip.
|
|
238
|
+
* The default is `false`, which means the new tab will be added to the end of the tab strip.
|
|
239
|
+
*/
|
|
240
|
+
insert?: number | boolean;
|
|
241
|
+
/** A boolean value indicating whether the new tab should be considered a child of the current tab (default is `false`). */
|
|
242
|
+
setParent?: boolean;
|
|
243
|
+
/** A boolean value that makes the tab being opened inside a incognito mode/private mode window. */
|
|
244
|
+
incognito?: boolean;
|
|
245
|
+
/** A boolean value has the opposite meaning of `active` and was added to achieve Greasemonkey 3.x compatibility. */
|
|
246
|
+
loadInBackground?: boolean;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface OpenTabObject {
|
|
250
|
+
/** Closes tab */
|
|
251
|
+
close(): void;
|
|
252
|
+
/** Set closed listener */
|
|
253
|
+
onclose?(): void;
|
|
254
|
+
closed: boolean;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface NotificationThis extends Notification {
|
|
258
|
+
id: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
type NotificationOnClick = (this: NotificationThis) => void;
|
|
262
|
+
/** `clicked` is `true` when `text` was set */
|
|
263
|
+
type NotificationOnDone = (this: NotificationThis, clicked: boolean) => void;
|
|
264
|
+
|
|
265
|
+
interface Notification {
|
|
266
|
+
/** A string containing the message to display in the notification (optional if highlight is set). */
|
|
267
|
+
text?: string;
|
|
268
|
+
/** The title of the notification. If not specified the script name is used. */
|
|
269
|
+
title?: string;
|
|
270
|
+
/**
|
|
271
|
+
* This tag will be used to identify this notification. This way you can update existing notifications
|
|
272
|
+
* by calling `GM_notification` again and using the same tag. If you don't provide a tag,
|
|
273
|
+
* a new notification will be created every time.
|
|
274
|
+
*/
|
|
275
|
+
tag?: string;
|
|
276
|
+
/** The URL of an image to display in the notification. */
|
|
277
|
+
image?: string;
|
|
278
|
+
/** Flag whether to highlight the tab that sends the notification. */
|
|
279
|
+
highlight?: boolean;
|
|
280
|
+
/** Whether to play or not play a sound. */
|
|
281
|
+
silent?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* The time, in milliseconds, after which the notification
|
|
284
|
+
* should automatically close. `0` = disabled.
|
|
285
|
+
*/
|
|
286
|
+
timeout?: number;
|
|
287
|
+
/**
|
|
288
|
+
* A URL to load when the user clicks on the notification. You can prevent loading the URL
|
|
289
|
+
* by calling `event.preventDefault()` in the `onclick` event handler.
|
|
290
|
+
*/
|
|
291
|
+
url?: string;
|
|
292
|
+
/**
|
|
293
|
+
* Called when the notification is closed (no matter if this was
|
|
294
|
+
* triggered by a timeout or a click) or the tab was highlighted.
|
|
295
|
+
*/
|
|
296
|
+
onclick?: NotificationOnClick;
|
|
297
|
+
/** Called in case the user clicks the notification. */
|
|
298
|
+
ondone?: NotificationOnDone;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
interface TextNotification extends Notification {
|
|
302
|
+
/** Text of the notification (optional if highlight is set) */
|
|
303
|
+
text: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface HighlightNotification extends Notification {
|
|
307
|
+
/** A string containing the message to display in the notification. */
|
|
308
|
+
text?: undefined;
|
|
309
|
+
/** Whether to highlight the tab that sends the notfication (required unless text is set) */
|
|
310
|
+
highlight: true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
type NotificationDetails = TextNotification | HighlightNotification;
|
|
314
|
+
|
|
315
|
+
// Interfaces for GM_info
|
|
316
|
+
|
|
269
317
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
318
|
+
* The metadata that the user can override in the settings
|
|
319
|
+
* for example run-at or excludes
|
|
272
320
|
*/
|
|
273
|
-
|
|
321
|
+
interface ScriptMetadataOverrides {
|
|
322
|
+
merge_connects: boolean;
|
|
323
|
+
merge_excludes: boolean;
|
|
324
|
+
merge_includes: boolean;
|
|
325
|
+
merge_matches: boolean;
|
|
326
|
+
orig_connects: string[];
|
|
327
|
+
orig_excludes: string[];
|
|
328
|
+
orig_includes: string[];
|
|
329
|
+
orig_matches: string[];
|
|
330
|
+
orig_noframes: boolean | null;
|
|
331
|
+
orig_run_at: string | null;
|
|
332
|
+
orig_run_in: string[] | null;
|
|
333
|
+
use_blockers: string[];
|
|
334
|
+
use_connects: string[];
|
|
335
|
+
use_excludes: string[];
|
|
336
|
+
use_includes: string[];
|
|
337
|
+
use_matches: string[];
|
|
338
|
+
}
|
|
339
|
+
|
|
274
340
|
/**
|
|
275
|
-
*
|
|
276
|
-
*
|
|
341
|
+
* The options that the user of the userscript
|
|
342
|
+
* can set in the settings (!== overrides)
|
|
277
343
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
merge_matches: boolean
|
|
308
|
-
orig_connects: string[]
|
|
309
|
-
orig_excludes: string[]
|
|
310
|
-
orig_includes: string[]
|
|
311
|
-
orig_matches: string[]
|
|
312
|
-
orig_noframes: string | null
|
|
313
|
-
orig_run_at: string | null
|
|
314
|
-
use_blockers: string[]
|
|
315
|
-
use_connects: string[]
|
|
316
|
-
use_excludes: string[]
|
|
317
|
-
use_includes: string[]
|
|
318
|
-
use_matches: string[]
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* The options that the user of the userscript
|
|
323
|
-
* can set in the settings (!== overrides)
|
|
324
|
-
*/
|
|
325
|
-
interface ScriptSettings {
|
|
326
|
-
check_for_updates: boolean
|
|
327
|
-
comment: string | null
|
|
328
|
-
compat_foreach: boolean
|
|
329
|
-
compat_metadata: boolean
|
|
330
|
-
compat_powerful_this: boolean | null
|
|
331
|
-
compat_prototypes: boolean
|
|
332
|
-
compat_wrappedjsobject: boolean
|
|
333
|
-
compatopts_for_requires: boolean
|
|
334
|
-
noframes: boolean | null
|
|
335
|
-
run_at: string
|
|
336
|
-
sandbox: string | null
|
|
337
|
-
tab_types: string | null
|
|
338
|
-
unwrap: boolean | null
|
|
339
|
-
|
|
340
|
-
override: ScriptMetadataOverrides
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* The resources from the metadata block (@resources)
|
|
345
|
-
* that tampermonkey should preload
|
|
346
|
-
*/
|
|
347
|
-
interface ScriptResource {
|
|
348
|
-
name: string
|
|
349
|
-
url?: string
|
|
350
|
-
content?: string
|
|
351
|
-
meta?: string
|
|
352
|
-
error?: string
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
interface WebRequestRule {
|
|
356
|
-
selector:
|
|
357
|
-
| {
|
|
358
|
-
include?: string | string[]
|
|
359
|
-
match?: string | string[]
|
|
360
|
-
exclude?: string | string[]
|
|
361
|
-
}
|
|
362
|
-
| string
|
|
363
|
-
action:
|
|
364
|
-
| string
|
|
365
|
-
| {
|
|
366
|
-
cancel?: boolean
|
|
367
|
-
redirect?:
|
|
368
|
-
| {
|
|
369
|
-
url: string
|
|
370
|
-
from?: string
|
|
371
|
-
to?: string
|
|
372
|
-
}
|
|
373
|
-
| string
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* `.. | null` means if it was not explicitely set in the metadata
|
|
379
|
-
* block it is null
|
|
380
|
-
*/
|
|
381
|
-
interface ScriptMetadata {
|
|
382
|
-
antifeatures: Record<string, Record<string, string>>
|
|
383
|
-
author: string | null
|
|
384
|
-
|
|
385
|
-
blockers: string[]
|
|
386
|
-
|
|
387
|
-
copyright: string | null
|
|
388
|
-
deleted?: number
|
|
389
|
-
description: string | null
|
|
390
|
-
description_i18n: Record<string, string> | null
|
|
391
|
-
downloadURL: string | null
|
|
392
|
-
enabled?: boolean
|
|
393
|
-
evilness: number
|
|
394
|
-
excludes: string[]
|
|
395
|
-
fileURL?: string | null
|
|
396
|
-
grant: string[]
|
|
397
|
-
header: string
|
|
398
|
-
homepage: string | null
|
|
399
|
-
icon: string | null
|
|
400
|
-
icon64: string | null
|
|
401
|
-
includes: string[]
|
|
402
|
-
lastModified: number
|
|
403
|
-
matches: string[]
|
|
404
|
-
name: string
|
|
405
|
-
name_i18n: Record<string, string> | null
|
|
406
|
-
namespace: string | null
|
|
407
|
-
options: ScriptSettings
|
|
408
|
-
|
|
409
|
-
position: number
|
|
410
|
-
resources: ScriptResource[]
|
|
344
|
+
interface ScriptSettings {
|
|
345
|
+
check_for_updates: boolean;
|
|
346
|
+
comment: string | null;
|
|
347
|
+
compat_foreach: boolean;
|
|
348
|
+
compat_metadata: boolean;
|
|
349
|
+
compat_powerful_this: boolean | null;
|
|
350
|
+
compat_wrappedjsobject: boolean;
|
|
351
|
+
compatopts_for_requires: boolean;
|
|
352
|
+
noframes: boolean | null;
|
|
353
|
+
run_at: string;
|
|
354
|
+
run_in: string[];
|
|
355
|
+
sandbox: string | null;
|
|
356
|
+
tags: string[];
|
|
357
|
+
unwrap: boolean | null;
|
|
358
|
+
user_modified: number | null;
|
|
359
|
+
|
|
360
|
+
override: ScriptMetadataOverrides;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
interface UADataValues {
|
|
364
|
+
brands?: {
|
|
365
|
+
brand: string;
|
|
366
|
+
version: string;
|
|
367
|
+
}[];
|
|
368
|
+
mobile?: boolean;
|
|
369
|
+
platform?: string;
|
|
370
|
+
architecture?: string;
|
|
371
|
+
bitness?: string;
|
|
372
|
+
}
|
|
411
373
|
|
|
412
374
|
/**
|
|
413
|
-
*
|
|
375
|
+
* The resources from the metadata block (@resources)
|
|
376
|
+
* that tampermonkey should preload
|
|
414
377
|
*/
|
|
415
|
-
|
|
378
|
+
interface ScriptResource {
|
|
379
|
+
name: string;
|
|
380
|
+
url?: string;
|
|
381
|
+
content?: string;
|
|
382
|
+
meta?: string;
|
|
383
|
+
error?: string;
|
|
384
|
+
}
|
|
416
385
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
386
|
+
interface WebRequestRule {
|
|
387
|
+
selector: {
|
|
388
|
+
include?: string | string[];
|
|
389
|
+
match?: string | string[];
|
|
390
|
+
exclude?: string | string[];
|
|
391
|
+
} | string;
|
|
392
|
+
action: string | {
|
|
393
|
+
cancel?: boolean;
|
|
394
|
+
redirect?: {
|
|
395
|
+
url: string;
|
|
396
|
+
from?: string;
|
|
397
|
+
to?: string;
|
|
398
|
+
} | string;
|
|
399
|
+
};
|
|
420
400
|
}
|
|
421
|
-
system?: boolean
|
|
422
|
-
unwrap: boolean
|
|
423
|
-
updateURL: string | null
|
|
424
|
-
uuid: string
|
|
425
|
-
version: string
|
|
426
|
-
webRequest: WebRequestRule[] | null
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
interface ScriptInfo {
|
|
430
|
-
downloadMode: 'native' | 'browser' | 'disabled'
|
|
431
|
-
isFirstPartyIsolation?: boolean
|
|
432
|
-
isIncognito: boolean
|
|
433
|
-
script: ScriptMetadata
|
|
434
|
-
sandboxMode: 'js' | 'raw' | 'dom'
|
|
435
401
|
|
|
436
402
|
/**
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* for other managers
|
|
403
|
+
* `.. | null` means if it was not explicitely set in the metadata
|
|
404
|
+
* block it is null
|
|
440
405
|
*/
|
|
441
|
-
|
|
406
|
+
interface ScriptMetadata {
|
|
407
|
+
antifeatures: Record<string, Record<string, string>>;
|
|
408
|
+
author: string | null;
|
|
409
|
+
|
|
410
|
+
blockers: string[];
|
|
411
|
+
connects: string[];
|
|
412
|
+
copyright: string | null;
|
|
413
|
+
deleted?: number;
|
|
414
|
+
description: string;
|
|
415
|
+
description_i18n: Record<string, string> | null;
|
|
416
|
+
downloadURL: string | null;
|
|
417
|
+
enabled?: boolean;
|
|
418
|
+
evilness: number;
|
|
419
|
+
excludes: string[];
|
|
420
|
+
fileURL?: string | null;
|
|
421
|
+
grant: string[];
|
|
422
|
+
header: string | null;
|
|
423
|
+
homepage: string | null;
|
|
424
|
+
icon: string | null;
|
|
425
|
+
icon64: string | null;
|
|
426
|
+
includes: string[];
|
|
427
|
+
lastModified: number;
|
|
428
|
+
matches: string[];
|
|
429
|
+
name: string;
|
|
430
|
+
name_i18n: Record<string, string> | null;
|
|
431
|
+
namespace: string | null;
|
|
432
|
+
options: ScriptSettings;
|
|
433
|
+
|
|
434
|
+
position: number;
|
|
435
|
+
resources: ScriptResource[];
|
|
442
436
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
437
|
+
/**
|
|
438
|
+
* Never null, defaults to document-idle
|
|
439
|
+
*/
|
|
440
|
+
"run-at": string;
|
|
441
|
+
"run-in": string[] | null;
|
|
442
|
+
|
|
443
|
+
supportURL: string | null;
|
|
444
|
+
sync?: {
|
|
445
|
+
imported?: number;
|
|
446
|
+
};
|
|
447
|
+
system?: boolean;
|
|
448
|
+
unwrap: boolean | null;
|
|
449
|
+
updateURL: string | null;
|
|
450
|
+
uuid: string;
|
|
451
|
+
version: string;
|
|
452
|
+
webRequest: WebRequestRule[] | null;
|
|
453
|
+
}
|
|
447
454
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
455
|
+
interface ScriptInfo {
|
|
456
|
+
/** Available since v5.3, only applicable to Firefox. */
|
|
457
|
+
container?: { // 5.3+ | Firefox only
|
|
458
|
+
id: string;
|
|
459
|
+
name?: string;
|
|
460
|
+
};
|
|
461
|
+
downloadMode: "native" | "browser" | "disabled";
|
|
462
|
+
isFirstPartyIsolation?: boolean;
|
|
463
|
+
isIncognito: boolean;
|
|
464
|
+
script: ScriptMetadata;
|
|
465
|
+
sandboxMode: "js" | "raw" | "dom";
|
|
451
466
|
|
|
452
|
-
|
|
467
|
+
/**
|
|
468
|
+
* In tampermonkey it's "Tampermonkey"
|
|
469
|
+
* but I'll leave it as string so this can be used
|
|
470
|
+
* for other managers
|
|
471
|
+
*/
|
|
472
|
+
scriptHandler: string;
|
|
453
473
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
474
|
+
scriptMetaStr: string | null;
|
|
475
|
+
scriptSource: string;
|
|
476
|
+
scriptUpdateURL: string | null;
|
|
477
|
+
scriptWillUpdate: boolean;
|
|
478
|
+
|
|
479
|
+
userAgentData: UADataValues;
|
|
480
|
+
|
|
481
|
+
/** This refers to tampermonkey's version */
|
|
482
|
+
version?: string;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
type ContentType = string | { type?: string; mimetype?: string };
|
|
486
|
+
|
|
487
|
+
// GM_webRequest
|
|
488
|
+
interface WebRequestRuleParam {
|
|
489
|
+
/**
|
|
490
|
+
* Specifies the URLs for which the rule should be triggered.
|
|
491
|
+
* String value is shortening for `{ include: [selector] }`.
|
|
492
|
+
*/
|
|
493
|
+
selector: string | {
|
|
494
|
+
/** URLs, patterns, and regexpes for rule triggering. */
|
|
495
|
+
include?: string | string[];
|
|
496
|
+
/** URLs and patterns for rule triggering. */
|
|
497
|
+
match?: string | string[];
|
|
498
|
+
/** URLs, patterns, and regexpes for not triggering the rule. */
|
|
499
|
+
exclude?: string | string[];
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* Specifies to do with the request.
|
|
503
|
+
* String value `cancel` is shortening for `{ cancel: true }`.
|
|
504
|
+
*/
|
|
505
|
+
action: "cancel" | {
|
|
506
|
+
/** Whether to cancel the request. */
|
|
507
|
+
cancel?: boolean;
|
|
508
|
+
/**
|
|
509
|
+
* Redirect to some URL which must be included in any
|
|
510
|
+
* `@match` or `@include` header.
|
|
511
|
+
* When a string, redirects to a given static URL.
|
|
512
|
+
*/
|
|
513
|
+
redirect?: string | {
|
|
487
514
|
/** A RegExp to extract some parts of the URL (for example `"([^:]+)://match.me/(.*)"`). */
|
|
488
|
-
from: string
|
|
515
|
+
from: string;
|
|
489
516
|
/** Pattern for substitution (for example `"$1://redirected.to/$2"`). */
|
|
490
|
-
to: string
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
517
|
+
to: string;
|
|
518
|
+
};
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
type WebRequestListener = (
|
|
523
|
+
/** The type of the action. */
|
|
524
|
+
info: "cancel" | "redirect",
|
|
525
|
+
message: "ok" | "error",
|
|
526
|
+
/** Info about the request and rule. */
|
|
527
|
+
details: {
|
|
528
|
+
/** The triggered rule */
|
|
529
|
+
rule: WebRequestRuleParam;
|
|
530
|
+
/** The URL of the request. */
|
|
531
|
+
url?: string;
|
|
532
|
+
/** Where the request was redirected. */
|
|
533
|
+
redirect_url?: string;
|
|
534
|
+
/** Error description. */
|
|
535
|
+
description?: string;
|
|
536
|
+
},
|
|
537
|
+
) => void;
|
|
538
|
+
|
|
539
|
+
// GM_cookie.*
|
|
540
|
+
interface Cookie {
|
|
541
|
+
/** The domain of the cookie. */
|
|
542
|
+
domain: string;
|
|
543
|
+
/** The first-party domain of the cookie. */
|
|
544
|
+
firstPartyDomain?: string;
|
|
545
|
+
/** The partition key of the cookie. */
|
|
546
|
+
partitionKey?: {
|
|
547
|
+
/** The top frame site of the cookie. */
|
|
548
|
+
topLevelSite?: string;
|
|
549
|
+
};
|
|
550
|
+
/** Indicates whether the cookie is a host-only cookie. */
|
|
551
|
+
hostOnly: boolean;
|
|
552
|
+
/** Indicates whether the cookie is an HTTP-only cookie. */
|
|
553
|
+
httpOnly: boolean;
|
|
554
|
+
/** The name of the cookie. */
|
|
555
|
+
name: string;
|
|
556
|
+
/** The path of the cookie. */
|
|
557
|
+
path: string;
|
|
558
|
+
/** The `SameSite` attribute of the cookie */
|
|
559
|
+
sameSite: string;
|
|
560
|
+
/** Whether the cookie requires a secure connection. */
|
|
561
|
+
secure: boolean;
|
|
562
|
+
/** Whether the cookie is a session cookie. */
|
|
563
|
+
session: boolean;
|
|
564
|
+
/** The value of the cookie. */
|
|
565
|
+
value: string;
|
|
566
|
+
/** The date the cookie expires in seconds since the Unix epoch. */
|
|
567
|
+
expirationDate?: number;
|
|
509
568
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
569
|
+
|
|
570
|
+
interface ListCookiesDetails {
|
|
571
|
+
/** The URL to retrieve cookies from (defaults to current document URL). */
|
|
572
|
+
url?: string;
|
|
573
|
+
/** The domain of the cookies to retrieve. */
|
|
574
|
+
domain?: string;
|
|
575
|
+
/** The name of the cookies to retrieve. */
|
|
576
|
+
name?: string;
|
|
577
|
+
/** The path of the cookies to retrieve. */
|
|
578
|
+
path?: string;
|
|
579
|
+
/**
|
|
580
|
+
* Object containing the partition key to be used for sent and received partitioned cookies.
|
|
581
|
+
* Use an empty object to retrieve all cookies.
|
|
582
|
+
*/
|
|
583
|
+
partitionKey?: {
|
|
584
|
+
/** String representing the top frame site of the cookies */
|
|
585
|
+
topLevelSite?: string;
|
|
586
|
+
};
|
|
522
587
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
588
|
+
|
|
589
|
+
type ListCookiesCallback = (
|
|
590
|
+
/** An array containing the retrieved cookies. */
|
|
591
|
+
cookies: Cookie[],
|
|
592
|
+
/** An error message if an error occurred, `null` otherwise. */
|
|
593
|
+
error: string | null,
|
|
594
|
+
) => void;
|
|
595
|
+
|
|
596
|
+
interface SetCookiesDetails {
|
|
597
|
+
/**
|
|
598
|
+
* The URL to associate the cookie with. If not specified,
|
|
599
|
+
* the cookie is associated with the current document's URL.
|
|
600
|
+
*/
|
|
601
|
+
url?: string;
|
|
602
|
+
/** The name of the cookie. */
|
|
603
|
+
name: string;
|
|
604
|
+
/** The value of the cookie. */
|
|
605
|
+
value: string;
|
|
606
|
+
/** The domain of the cookie. */
|
|
607
|
+
domain?: string;
|
|
608
|
+
/** The first-party domain of the cookie. */
|
|
609
|
+
firstPartyDomain?: string;
|
|
610
|
+
/** The partition key of the cookie. */
|
|
611
|
+
partitionKey?: {
|
|
612
|
+
/** The top frame site of the cookie. */
|
|
613
|
+
topLevelSite?: string;
|
|
614
|
+
};
|
|
615
|
+
/** The path of the cookie. */
|
|
616
|
+
path?: string;
|
|
617
|
+
/** Whether the cookie should only be sent over HTTPS. */
|
|
618
|
+
secure?: boolean;
|
|
619
|
+
/** Whether the cookie should be marked as `HttpOnly`. */
|
|
620
|
+
httpOnly?: boolean;
|
|
621
|
+
/**
|
|
622
|
+
* The expiration date of the cookie in seconds since the Unix epoch.
|
|
623
|
+
* If not specified, the cookie never expires.
|
|
624
|
+
*/
|
|
625
|
+
expirationDate?: number;
|
|
559
626
|
}
|
|
560
|
-
}
|
|
561
627
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
628
|
+
interface DeleteCookiesDetails {
|
|
629
|
+
/**
|
|
630
|
+
* The URL associated with the cookie. If `url` is not specified,
|
|
631
|
+
* the current document's URL will be used.
|
|
632
|
+
*/
|
|
633
|
+
url: string;
|
|
634
|
+
/** The name of the cookie to delete. */
|
|
635
|
+
name: string;
|
|
636
|
+
/** The first party domain of the cookie to delete. */
|
|
637
|
+
firstPartyDomain: string;
|
|
638
|
+
/** The partition key of the cookie to delete. */
|
|
639
|
+
partitionKey: {
|
|
640
|
+
/** The top frame site of the cookies. */
|
|
641
|
+
topLevelSite?: string;
|
|
642
|
+
};
|
|
643
|
+
}
|
|
568
644
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
/** The first-party domain of the cookie. */
|
|
582
|
-
firstPartyDomain?: string
|
|
583
|
-
/** The partition key of the cookie. */
|
|
584
|
-
partitionKey?: {
|
|
585
|
-
/** The top frame site of the cookie. */
|
|
586
|
-
topLevelSite?: string
|
|
645
|
+
interface AudioStateInfo {
|
|
646
|
+
/** Whether the tab is currently muted. */
|
|
647
|
+
isMuted?: boolean;
|
|
648
|
+
/**
|
|
649
|
+
* The reason why the tab was muted, if it is currently muted:
|
|
650
|
+
* - `user`: user action (e.g., mute button).
|
|
651
|
+
* - `capture`: tab capture API call.
|
|
652
|
+
* - `extension`: extension call.
|
|
653
|
+
*/
|
|
654
|
+
muteReason?: "user" | "capture" | "extension";
|
|
655
|
+
/** Whether the tab is currently playing audio. */
|
|
656
|
+
isAudible?: boolean;
|
|
587
657
|
}
|
|
588
|
-
/** The path of the cookie. */
|
|
589
|
-
path?: string
|
|
590
|
-
/** Whether the cookie should only be sent over HTTPS. */
|
|
591
|
-
secure?: boolean
|
|
592
|
-
/** Whether the cookie should be marked as `HttpOnly`. */
|
|
593
|
-
httpOnly?: boolean
|
|
594
|
-
/**
|
|
595
|
-
* The expiration date of the cookie in seconds since the Unix epoch.
|
|
596
|
-
* If not specified, the cookie never expires.
|
|
597
|
-
*/
|
|
598
|
-
expirationDate?: number
|
|
599
|
-
}
|
|
600
658
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
659
|
+
type AudioStateCallback = (
|
|
660
|
+
/** An object representing the retrieved state */
|
|
661
|
+
info: Tampermonkey.AudioStateInfo,
|
|
662
|
+
) => void;
|
|
663
|
+
|
|
664
|
+
type ErrorCallback = (
|
|
665
|
+
/** Contains an error message if the action fails, otherwise it is `undefined`. */
|
|
666
|
+
error?: string,
|
|
667
|
+
) => void;
|
|
668
|
+
|
|
669
|
+
interface AudioStateListenerInfo {
|
|
670
|
+
/** Mute reason or `false` if not muted. */
|
|
671
|
+
muted?: string | false;
|
|
672
|
+
/** Whether the tab is currently playing audio. */
|
|
673
|
+
audible?: boolean;
|
|
615
674
|
}
|
|
616
|
-
|
|
675
|
+
|
|
676
|
+
type AudioStateListener = (
|
|
677
|
+
/** An object representing the retrieved state change. */
|
|
678
|
+
info: Tampermonkey.AudioStateListenerInfo,
|
|
679
|
+
) => void;
|
|
617
680
|
}
|
|
618
681
|
|
|
619
682
|
/**
|
|
620
683
|
* The unsafeWindow object provides full access to the pages JavaScript
|
|
621
684
|
* functions and variables
|
|
622
685
|
*/
|
|
623
|
-
declare var unsafeWindow:
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
686
|
+
declare var unsafeWindow:
|
|
687
|
+
& Window
|
|
688
|
+
& Omit<
|
|
689
|
+
typeof globalThis,
|
|
690
|
+
| "GM_addElement"
|
|
691
|
+
| "GM_addStyle"
|
|
692
|
+
| "GM_addValueChangeListener"
|
|
693
|
+
| "GM_audio"
|
|
694
|
+
| "GM_cookie"
|
|
695
|
+
| "GM_deleteValue"
|
|
696
|
+
| "GM_deleteValues"
|
|
697
|
+
| "GM_download"
|
|
698
|
+
| "GM_getResourceText"
|
|
699
|
+
| "GM_getResourceURL"
|
|
700
|
+
| "GM_getTab"
|
|
701
|
+
| "GM_getTabs"
|
|
702
|
+
| "GM_getValue"
|
|
703
|
+
| "GM_getValues"
|
|
704
|
+
| "GM_info"
|
|
705
|
+
| "GM_listValues"
|
|
706
|
+
| "GM_log"
|
|
707
|
+
| "GM_notification"
|
|
708
|
+
| "GM_openInTab"
|
|
709
|
+
| "GM_registerMenuCommand"
|
|
710
|
+
| "GM_removeValueChangeListener"
|
|
711
|
+
| "GM_saveTab"
|
|
712
|
+
| "GM_setClipboard"
|
|
713
|
+
| "GM_setValue"
|
|
714
|
+
| "GM_setValues"
|
|
715
|
+
| "GM_unregisterMenuCommand"
|
|
716
|
+
| "GM_xmlhttpRequest"
|
|
717
|
+
| "GM_webRequest"
|
|
718
|
+
| "GM"
|
|
719
|
+
>;
|
|
650
720
|
|
|
651
721
|
/**
|
|
652
|
-
* Patched onurlchange attribute based on document {@link https://www.tampermonkey.net/documentation.php#meta:grant}
|
|
653
|
-
* @url https://www.tampermonkey.net/documentation.php#meta:grant
|
|
722
|
+
* Patched onurlchange attribute based on document {@link https://www.tampermonkey.net/documentation.php?q=grant#meta:grant}
|
|
723
|
+
* @url https://www.tampermonkey.net/documentation.php?q=grant#meta:grant
|
|
654
724
|
*/
|
|
655
725
|
interface Window {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
type: 'urlchange',
|
|
669
|
-
listener: (urlObject: { url: string }) => void
|
|
670
|
-
): void
|
|
726
|
+
/**
|
|
727
|
+
* check before use addEventListener
|
|
728
|
+
*
|
|
729
|
+
* According to the documentation and code, the value can currently only be of type null
|
|
730
|
+
* @url https://www.tampermonkey.net/documentation.php?q=grant#meta:grant
|
|
731
|
+
* @example
|
|
732
|
+
* if (window.onurlchange === null) {
|
|
733
|
+
* window.addEventListener('urlchange', (info) => console.log(info));
|
|
734
|
+
* }
|
|
735
|
+
*/
|
|
736
|
+
onurlchange: null;
|
|
737
|
+
addEventListener(type: "urlchange", listener: (urlObject: { url: string }) => void): void;
|
|
671
738
|
}
|
|
672
739
|
|
|
673
740
|
/**
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* with a content security policy (CSP).
|
|
741
|
+
* Adds new elements to the page that Tampermonkey is running on. This can be useful for
|
|
742
|
+
* a variety of purposes, such as adding `script` and `img` tags if the page limits
|
|
743
|
+
* these elements with a content security policy (CSP).
|
|
678
744
|
*
|
|
679
745
|
* The resulting HTML element will be attached to document head or body.
|
|
680
746
|
*
|
|
681
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
747
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_addElement
|
|
682
748
|
* @param tagName Specifies the HTML element tag name.
|
|
683
749
|
* @param attributes Attributes that applied to the HTML element.
|
|
684
750
|
* For suitable `attributes`, please consult the appropriate documentation. For example:
|
|
@@ -688,15 +754,14 @@ interface Window {
|
|
|
688
754
|
* - [`style` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style)
|
|
689
755
|
* @returns The injected HTML element
|
|
690
756
|
*/
|
|
691
|
-
declare function GM_addElement(tagName: string, attributes: object): HTMLElement
|
|
757
|
+
declare function GM_addElement(tagName: string, attributes: object): HTMLElement;
|
|
692
758
|
|
|
693
759
|
/**
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* with a content security policy (CSP).
|
|
760
|
+
* Adds new elements to the page that Tampermonkey is running on. This can be useful for
|
|
761
|
+
* a variety of purposes, such as adding `script` and `img` tags if the page limits
|
|
762
|
+
* these elements with a content security policy (CSP).
|
|
698
763
|
*
|
|
699
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
764
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_addElement
|
|
700
765
|
* @param parentNode The node the resulting HTML element will be attached to.
|
|
701
766
|
* @param tagName Specifies the HTML element tag name.
|
|
702
767
|
* @param attributes Attributes that applied to the HTML element.
|
|
@@ -709,101 +774,136 @@ declare function GM_addElement(tagName: string, attributes: object): HTMLElement
|
|
|
709
774
|
* @returns The injected HTML element
|
|
710
775
|
*/
|
|
711
776
|
declare function GM_addElement(
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
): HTMLElement
|
|
777
|
+
parentNode: Element,
|
|
778
|
+
tagName: string,
|
|
779
|
+
attributes: object,
|
|
780
|
+
): HTMLElement;
|
|
716
781
|
|
|
717
782
|
// Styles
|
|
718
783
|
|
|
719
784
|
/**
|
|
720
785
|
* Applies the given style to the document.
|
|
721
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
786
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_addStyle
|
|
722
787
|
* @param css The styles to apply.
|
|
723
788
|
* @returns The injected style element.
|
|
724
789
|
*/
|
|
725
|
-
declare function GM_addStyle(css: string): HTMLStyleElement
|
|
790
|
+
declare function GM_addStyle(css: string): HTMLStyleElement;
|
|
726
791
|
|
|
727
792
|
// Storage
|
|
728
793
|
|
|
729
794
|
/**
|
|
730
795
|
* Sets the value of a specific key in the userscript's storage.
|
|
731
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_setValue
|
|
796
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_setValue
|
|
732
797
|
* @param name A string specifying the key for which the value should be set.
|
|
733
798
|
* @param value The value to be set for the key.
|
|
734
799
|
*/
|
|
735
|
-
declare function GM_setValue(name: string, value:
|
|
800
|
+
declare function GM_setValue(name: string, value: Tampermonkey.StorageValue): void;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Sets multiple key-value pairs in the userscript's storage simultaneously.
|
|
804
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_setValues
|
|
805
|
+
* @param values An object where each key-value pair corresponds to a key and the value to be set for that key.
|
|
806
|
+
*/
|
|
807
|
+
declare function GM_setValues(values: Record<string, Tampermonkey.StorageValue>): void;
|
|
736
808
|
|
|
737
809
|
/**
|
|
738
810
|
* Adds a listener for changes to the value of a specific key in the userscript's storage.
|
|
739
811
|
* This functionality can be used by scripts of different browser tabs to communicate with each other.
|
|
740
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_addValueChangeListener
|
|
812
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_addValueChangeListener
|
|
741
813
|
* @param name A string specifying the key for which changes should be monitored.
|
|
742
814
|
* @param listener A callback function that will be called when the value of the key changes.
|
|
743
815
|
* @returns A `listenerId` value that can be used to remove the listener later using `GM_removeValueChangeListener`.
|
|
744
816
|
*/
|
|
745
|
-
declare function GM_addValueChangeListener(
|
|
746
|
-
name: string,
|
|
747
|
-
listener: Tampermonkey.ValueChangeListener
|
|
748
|
-
): number
|
|
817
|
+
declare function GM_addValueChangeListener(name: string, listener: Tampermonkey.ValueChangeListener): number;
|
|
749
818
|
|
|
750
819
|
/**
|
|
751
|
-
* Removes
|
|
752
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_removeValueChangeListener
|
|
820
|
+
* Removes the change listener with the specified ID.
|
|
821
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_removeValueChangeListener
|
|
822
|
+
* @param listenerId The ID of the listener to be removed.
|
|
753
823
|
*/
|
|
754
|
-
declare function GM_removeValueChangeListener(listenerId: number): void
|
|
824
|
+
declare function GM_removeValueChangeListener(listenerId: number): void;
|
|
755
825
|
|
|
756
826
|
/**
|
|
757
827
|
* Retrieves the value of a specific key in the extension's storage.
|
|
758
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_getValue
|
|
828
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_getValue
|
|
759
829
|
* @param name A string specifying the key for which the value should be retrieved.
|
|
760
830
|
* @param defaultValue A default value to be returned if the key does not exist in the extension's storage.
|
|
761
831
|
* @returns The value of the specified key from the extension's storage, or the default value if the key does not exist.
|
|
762
832
|
*/
|
|
763
|
-
declare function GM_getValue<TValue>(
|
|
764
|
-
name: string,
|
|
765
|
-
defaultValue?: TValue
|
|
766
|
-
): TValue
|
|
833
|
+
declare function GM_getValue<TValue>(name: string, defaultValue?: TValue): TValue;
|
|
767
834
|
|
|
768
835
|
/**
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
* @
|
|
836
|
+
* Retrieves the values of multiple keys in the userscript's storage. It can also provide
|
|
837
|
+
* default values if the keys do not exist.
|
|
838
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_getValues
|
|
839
|
+
* @param keys An array of strings specifying the keys for which the values should be retrieved
|
|
840
|
+
* @returns An object containing the values of the specified keys from the userscript's storage,
|
|
841
|
+
* or the default values if the keys do not exist.
|
|
772
842
|
*/
|
|
773
|
-
declare function
|
|
843
|
+
declare function GM_getValues<
|
|
844
|
+
TValues extends object,
|
|
845
|
+
TKeys extends readonly (keyof TValues & string)[] = readonly (keyof TValues & string)[],
|
|
846
|
+
>(keys: TKeys): Pick<TValues, TKeys[number]>;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Retrieves the values of multiple keys in the userscript's storage. It can also provide
|
|
850
|
+
* default values if the keys do not exist.
|
|
851
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_getValues
|
|
852
|
+
* @param defaults An object specifying the default values to be returned if the keys do not exist.
|
|
853
|
+
* @returns An object containing the values of the specified keys from the userscript's storage,
|
|
854
|
+
* or the default values if the keys do not exist.
|
|
855
|
+
*/
|
|
856
|
+
declare function GM_getValues<TDefaults extends { [key: string]: Tampermonkey.StorageValue }>(
|
|
857
|
+
defaults: TDefaults,
|
|
858
|
+
): TDefaults;
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Deletes `key` from the userscript's storage.
|
|
862
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_deleteValue
|
|
863
|
+
* @param key A string specifying the key that should be deleted from storage.
|
|
864
|
+
*/
|
|
865
|
+
declare function GM_deleteValue(key: string): void;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Deletes multiple keys from the userscript's storage simultaneously.
|
|
869
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_deleteValues
|
|
870
|
+
* @param keys An array of strings specifying the keys to be deleted from the userscript's storage.
|
|
871
|
+
*/
|
|
872
|
+
declare function GM_deleteValues(keys: string[]): void;
|
|
774
873
|
|
|
775
874
|
/**
|
|
776
875
|
* Returns a list of keys of all stored data.
|
|
777
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_listValues
|
|
876
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_listValues
|
|
778
877
|
*/
|
|
779
|
-
declare function GM_listValues(): string[]
|
|
878
|
+
declare function GM_listValues(): string[];
|
|
780
879
|
|
|
781
880
|
// Resources
|
|
782
881
|
|
|
783
882
|
/**
|
|
784
|
-
* Retrieves the text of a resource (such as a JavaScript or CSS file)
|
|
785
|
-
*
|
|
786
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_getResourceText
|
|
883
|
+
* Retrieves the text of a resource (such as a JavaScript or CSS file) that has
|
|
884
|
+
* been included in a userscript via a `@resource` tag at the script header.
|
|
885
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_getResource#api:GM_getResourceText
|
|
787
886
|
* @param name The name of the resource to retrieve.
|
|
788
887
|
* @returns The text of the resource as a string.
|
|
789
888
|
*/
|
|
790
|
-
declare function GM_getResourceText(name: string): string
|
|
889
|
+
declare function GM_getResourceText(name: string): string;
|
|
791
890
|
|
|
792
891
|
/**
|
|
793
|
-
*
|
|
794
|
-
* header
|
|
795
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_getResourceURL
|
|
892
|
+
* Retrieves the URL of a resource (such as a CSS or image file) that has been included
|
|
893
|
+
* in the userscript via a `@resource` tag at the script header.
|
|
894
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_getResource#api:GM_getResourceURL
|
|
796
895
|
* @param name The name of the resource to retrieve.
|
|
797
896
|
* @returns The URL of the resource as a string.
|
|
798
897
|
*/
|
|
799
|
-
declare function GM_getResourceURL(name: string): string
|
|
898
|
+
declare function GM_getResourceURL(name: string): string;
|
|
800
899
|
|
|
801
900
|
// Menu commands
|
|
802
901
|
|
|
803
902
|
/**
|
|
804
|
-
* Adds a new entry to the userscript's menu in the browser,
|
|
805
|
-
*
|
|
806
|
-
*
|
|
903
|
+
* Adds a new entry to the userscript's menu in the browser, and specifies a function
|
|
904
|
+
* to be called when the menu item is selected. Menu items created from different frames
|
|
905
|
+
* are merged into a single menu entry if `name`, `title` and `accessKey` are the same.
|
|
906
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_registerMenuCommand#api:GM_registerMenuCommand
|
|
807
907
|
* @param name A string containing the text to display for the menu item.
|
|
808
908
|
* @param onclick A function to be called when the menu item is selected.
|
|
809
909
|
* The function will be passed a single parameter,
|
|
@@ -813,130 +913,149 @@ declare function GM_getResourceURL(name: string): string
|
|
|
813
913
|
* @returns A menu entry ID that can be used to unregister the command.
|
|
814
914
|
*/
|
|
815
915
|
declare function GM_registerMenuCommand(
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
| {
|
|
916
|
+
name: string,
|
|
917
|
+
onClick: (
|
|
918
|
+
event: MouseEvent | KeyboardEvent,
|
|
919
|
+
) => void,
|
|
920
|
+
optionsOrAccessKey?: string | {
|
|
821
921
|
/**
|
|
822
922
|
* An optional number that was returned by a previous `GM_registerMenuCommand` call.
|
|
823
923
|
* If specified, the according menu item will be updated with the new options.
|
|
824
924
|
* If not specified or the menu item can't be found, a new menu item will be created.
|
|
825
925
|
*/
|
|
826
|
-
id?: number | string
|
|
926
|
+
id?: number | string;
|
|
827
927
|
/**
|
|
828
928
|
* An optional access key for the menu item. This can be used to create a shortcut for the menu item.
|
|
829
929
|
* For example, if the access key is "s", the user can select the menu item by pressing "s"
|
|
830
930
|
* when Tampermonkey's popup-menu is open. Please note that there are browser-wide shortcuts
|
|
831
|
-
* configurable to open Tampermonkey's popup-menu
|
|
931
|
+
* configurable to open Tampermonkey's popup-menu (`chrome://extensions/shortcuts` in Chrome,
|
|
932
|
+
* `about:addons` + "Manage Extension Shortcuts" in Firefox)
|
|
832
933
|
*/
|
|
833
|
-
accessKey?: string
|
|
934
|
+
accessKey?: string;
|
|
834
935
|
/**
|
|
835
936
|
* An optional boolean parameter that specifies whether the popup menu should be closed
|
|
836
937
|
* after the menu item is clicked. The default value is `true`. Please note that this setting
|
|
837
938
|
* has no effect on the menu command section that is added to the page's context menu.
|
|
838
939
|
*/
|
|
839
|
-
autoClose?: boolean
|
|
940
|
+
autoClose?: boolean;
|
|
840
941
|
/**
|
|
841
942
|
* An optional string that specifies the title of the menu item. This is displayed
|
|
842
943
|
* as a tooltip when the user hovers the mouse over the menu item.
|
|
843
944
|
*/
|
|
844
|
-
title?: string
|
|
845
|
-
|
|
846
|
-
): number
|
|
945
|
+
title?: string;
|
|
946
|
+
},
|
|
947
|
+
): number;
|
|
847
948
|
|
|
848
949
|
/**
|
|
849
950
|
* Removes an existing entry from the userscript's menu in the browser
|
|
850
951
|
* that was previously registered by `GM_registerMenuCommand` or `GM.registerMenuCommand`
|
|
851
952
|
* with the given menu command ID.
|
|
852
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_unregisterMenuCommand
|
|
953
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_registerMenuCommand#api:GM_unregisterMenuCommand
|
|
853
954
|
* @param menuCommandId The id of the menu item to remove.
|
|
854
955
|
*/
|
|
855
|
-
declare function GM_unregisterMenuCommand(menuCommandId: number): void
|
|
956
|
+
declare function GM_unregisterMenuCommand(menuCommandId: number): void;
|
|
856
957
|
|
|
857
958
|
// Requests
|
|
858
959
|
|
|
859
960
|
/**
|
|
860
|
-
* Sends an HTTP request and handles the response.
|
|
861
|
-
*
|
|
961
|
+
* Sends an HTTP request and handles the response. `GM_xmlhttpRequest` is dispatched
|
|
962
|
+
* by Tampermonkey's background context.
|
|
963
|
+
* If you want to use this method then please also check the documentation about
|
|
964
|
+
* [`@connect`](https://www.tampermonkey.net/documentation.php?q=meta:connect).
|
|
965
|
+
*
|
|
966
|
+
* **Proxy.** Tampermonkey does not implement its own proxy resolution (PAC, WPAD, WinHTTP, or NO_PROXY).
|
|
967
|
+
* Requests use the browser's native networking stack, so proxy settings follow whatever the browser is
|
|
968
|
+
* configured to use. The `proxy` property on the request details allows you to override this and route a
|
|
969
|
+
* specific request through an explicit proxy server.
|
|
970
|
+
*
|
|
971
|
+
* **Certificates.** No custom certificate or trust-store handling is performed. Requests use the browser's
|
|
972
|
+
* TLS stack, so they trust whichever root certificates the browser trusts (e.g., OS trust store on Chrome,
|
|
973
|
+
* Firefox's own certificate database on Firefox).
|
|
974
|
+
*
|
|
975
|
+
* **Authentication Challenges (401/407).** HTTP 401 and 407 responses come from the destination server or
|
|
976
|
+
* proxy before Tampermonkey can intercept them. They must be resolved at the browser or OS proxy-authentication
|
|
977
|
+
* level, or by providing credentials via the user/password properties.
|
|
978
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_xmlhttpRequest
|
|
862
979
|
* @param details An object containing the details of the request to be sent
|
|
863
980
|
* and the callback functions to be called when the response is received.
|
|
864
981
|
*/
|
|
865
982
|
declare function GM_xmlhttpRequest<TContext = any>( // eslint-disable-line @definitelytyped/no-unnecessary-generics
|
|
866
|
-
|
|
867
|
-
): Tampermonkey.AbortHandle<void
|
|
983
|
+
details: Tampermonkey.Request<TContext>,
|
|
984
|
+
): Tampermonkey.AbortHandle<void>;
|
|
868
985
|
|
|
869
986
|
/**
|
|
870
|
-
* Downloads a file from a specified URL and
|
|
987
|
+
* Downloads a file from a specified URL and saves it to the user's local machine.
|
|
871
988
|
* Note: The browser might modify the desired filename. Especially a file extension might
|
|
872
989
|
* be added if the browser finds this to be safe to download at the current OS.
|
|
873
|
-
*
|
|
990
|
+
*
|
|
991
|
+
* Depending on the download mode, `GM_info` provides a property called `downloadMode`
|
|
992
|
+
* which is set to one of the following values: `native`, `disabled` or `browser`.
|
|
993
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_download
|
|
874
994
|
* @param details Details about the download.
|
|
875
995
|
*/
|
|
876
|
-
declare function GM_download(
|
|
877
|
-
details: Tampermonkey.DownloadRequest
|
|
878
|
-
): Tampermonkey.AbortHandle<boolean>
|
|
996
|
+
declare function GM_download(details: Tampermonkey.DownloadRequest): Tampermonkey.AbortHandle<boolean>;
|
|
879
997
|
/**
|
|
880
|
-
* Downloads a file from a specified URL and
|
|
998
|
+
* Downloads a file from a specified URL and saves it to the user's local machine.
|
|
881
999
|
* Note: The browser might modify the desired filename. Especially a file extension might
|
|
882
1000
|
* be added if the browser finds this to be safe to download at the current OS.
|
|
883
|
-
*
|
|
884
|
-
*
|
|
1001
|
+
*
|
|
1002
|
+
* Depending on the download mode, `GM_info` provides a property called `downloadMode`
|
|
1003
|
+
* which is set to one of the following values: `native`, `disabled` or `browser`.
|
|
1004
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_download
|
|
1005
|
+
* @param url The URL of the file to download or a `Blob` or `File` object (v5.4.6226+). In case of a
|
|
1006
|
+
* string, this must be a valid URL and must point to a file that is accessible to the user.
|
|
885
1007
|
* @param name The name to use for the downloaded file. This should include the file's extension,
|
|
886
1008
|
* such as `.txt` or `.pdf`. For security reasons the file extension needs to be whitelisted
|
|
887
1009
|
* at Tampermonkey's options page
|
|
888
1010
|
*/
|
|
889
|
-
declare function GM_download(
|
|
890
|
-
url: string,
|
|
891
|
-
name: string
|
|
892
|
-
): Tampermonkey.AbortHandle<boolean>
|
|
1011
|
+
declare function GM_download(url: string | File | Blob, name: string): Tampermonkey.AbortHandle<boolean>;
|
|
893
1012
|
|
|
894
1013
|
// Tabs
|
|
895
1014
|
|
|
896
1015
|
/**
|
|
897
1016
|
* Saves information about a tab so that it can be retrieved later
|
|
898
1017
|
* using the `GM_getTab` function.
|
|
899
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_saveTab
|
|
1018
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_tabs#api:GM_saveTab
|
|
900
1019
|
* @param tab An object containing the information to be saved about the tab.
|
|
901
1020
|
* @param callback An optional callback function
|
|
902
1021
|
*/
|
|
903
|
-
declare function GM_saveTab(tab: object, callback?: () => void): void
|
|
1022
|
+
declare function GM_saveTab(tab: object, callback?: () => void): void;
|
|
904
1023
|
|
|
905
1024
|
/**
|
|
906
1025
|
* Gets a object that is persistent as long as this tab is open
|
|
907
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_getTab
|
|
908
|
-
* @param callback
|
|
1026
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_tabs#api:GM_getTab
|
|
1027
|
+
* @param callback A callback function that will be called with an object that is persistent as long as this tab is open.
|
|
909
1028
|
*/
|
|
910
|
-
declare function GM_getTab(callback: (obj: any) => void): void
|
|
1029
|
+
declare function GM_getTab(callback: (obj: any) => void): void;
|
|
911
1030
|
|
|
912
1031
|
/**
|
|
913
1032
|
* Gets all tab objects as a hash to communicate with other script instances
|
|
914
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_getTabs
|
|
1033
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_tabs#api:GM_getTabs
|
|
915
1034
|
* @param callback A callback function that will be called with the information about the tabs..
|
|
916
1035
|
*/
|
|
917
1036
|
declare function GM_getTabs(
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
): void
|
|
1037
|
+
callback: (
|
|
1038
|
+
/**
|
|
1039
|
+
* The `tabsMap` object that is passed to the callback function contains objects,
|
|
1040
|
+
* with each object representing the saved tab information stored by `GM_saveTab`.
|
|
1041
|
+
*/
|
|
1042
|
+
tabsMap: { [tabId: number]: any },
|
|
1043
|
+
) => void,
|
|
1044
|
+
): void;
|
|
926
1045
|
|
|
927
1046
|
// Utils
|
|
928
1047
|
|
|
929
1048
|
/**
|
|
930
1049
|
* Returns information about the script and Tampermonkey.
|
|
931
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
1050
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_info
|
|
932
1051
|
*/
|
|
933
|
-
declare var GM_info: Tampermonkey.ScriptInfo
|
|
1052
|
+
declare var GM_info: Tampermonkey.ScriptInfo;
|
|
934
1053
|
|
|
935
1054
|
/**
|
|
936
1055
|
* Logs a message to the console
|
|
937
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
1056
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_log
|
|
938
1057
|
*/
|
|
939
|
-
declare function GM_log(...message: any[]): void
|
|
1058
|
+
declare function GM_log(...message: any[]): void;
|
|
940
1059
|
|
|
941
1060
|
/**
|
|
942
1061
|
* Opens a new tab with this url.
|
|
@@ -951,16 +1070,16 @@ declare function GM_log(...message: any[]): void
|
|
|
951
1070
|
*
|
|
952
1071
|
* If neither `active` nor `loadInBackground` is given, then the tab will not be
|
|
953
1072
|
* focused.
|
|
954
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
1073
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_openInTab
|
|
955
1074
|
* @param url The URL of the page to open in the new tab.
|
|
956
1075
|
* @param options An object that can be used to customize the behavior of the new tab.
|
|
957
1076
|
* @returns An object with the function `close`, the listener `onclose` and a flag
|
|
958
1077
|
* called `closed`.
|
|
959
1078
|
*/
|
|
960
1079
|
declare function GM_openInTab(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
): Tampermonkey.OpenTabObject
|
|
1080
|
+
url: string,
|
|
1081
|
+
options?: Tampermonkey.OpenTabOptions | boolean,
|
|
1082
|
+
): Tampermonkey.OpenTabObject;
|
|
964
1083
|
|
|
965
1084
|
/**
|
|
966
1085
|
* Shows an HTML5 Desktop notification and/or highlight the current tab
|
|
@@ -968,127 +1087,163 @@ declare function GM_openInTab(
|
|
|
968
1087
|
*
|
|
969
1088
|
* Since v5.0, if no `url` and no `tag` is provided in `details` argument, the notification will close
|
|
970
1089
|
* when the userscript unloads (e.g. when the page is reloaded or the tab is closed).
|
|
971
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
1090
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_notification
|
|
972
1091
|
* @param details Notification parameters.
|
|
973
1092
|
* @param ondone A callback function that will be called when the notification is closed
|
|
974
1093
|
* (no matter if this was triggered by a timeout or a click) or the tab was highlighted.
|
|
975
1094
|
* If specified, used instead of `details.ondone`.
|
|
976
1095
|
*/
|
|
977
1096
|
declare function GM_notification(
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
): void
|
|
1097
|
+
details: Tampermonkey.NotificationDetails,
|
|
1098
|
+
ondone?: Tampermonkey.NotificationOnDone,
|
|
1099
|
+
): void;
|
|
981
1100
|
|
|
982
1101
|
/**
|
|
983
1102
|
* Shows an HTML5 Desktop notification and/or highlight the current tab
|
|
984
1103
|
* using a provided message and other optional parameters.
|
|
985
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
1104
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_notification
|
|
986
1105
|
* @param text A string containing the message to display in the notification.
|
|
987
1106
|
* @param title The title of the notification. If not specified, the script name is used.
|
|
988
1107
|
* @param image The URL of an image to display in the notification.
|
|
989
1108
|
* @param onClick A callback function that will be called when the user clicks on the notification.
|
|
990
1109
|
*/
|
|
991
1110
|
declare function GM_notification(
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
): void
|
|
1111
|
+
text: string,
|
|
1112
|
+
title?: string,
|
|
1113
|
+
image?: string,
|
|
1114
|
+
onClick?: Tampermonkey.NotificationOnClick,
|
|
1115
|
+
): void;
|
|
997
1116
|
|
|
998
1117
|
/**
|
|
999
1118
|
* Sets the text of the clipboard to a specified value.
|
|
1000
|
-
*
|
|
1001
|
-
* `{ type: 'text', mimetype: 'text/plain'}` or just a string expressing the
|
|
1002
|
-
* type ("text" or "html").
|
|
1003
|
-
* @url https://www.tampermonkey.net/documentation.php#api:GM_setClipboard
|
|
1119
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_setClipboard
|
|
1004
1120
|
* @param data The string to set as the clipboard text.
|
|
1005
|
-
* @param info A string expressing the type `text` or `html` or an object
|
|
1121
|
+
* @param info A string expressing the type `text` or `html` or an object
|
|
1122
|
+
* like `{ type: 'text', mimetype: 'text/plain'}`.
|
|
1006
1123
|
* @param callback An optional callback function that is called when the clipboard has been set.
|
|
1007
1124
|
*/
|
|
1008
1125
|
declare function GM_setClipboard(
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
): void
|
|
1126
|
+
data: string,
|
|
1127
|
+
info?: Tampermonkey.ContentType,
|
|
1128
|
+
callback?: () => void,
|
|
1129
|
+
): void;
|
|
1013
1130
|
|
|
1014
1131
|
/**
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* **Note
|
|
1020
|
-
*
|
|
1021
|
-
* @url https://www.tampermonkey.net/documentation.php
|
|
1132
|
+
* (Re-)registers rules for web request manipulations and the listener of triggered rules.
|
|
1133
|
+
* If you need to just register rules it's better to use `@webRequest` header.
|
|
1134
|
+
* `webRequest` proceeds only requests with types `sub_frame`, `script`, `xhr` and `websocket`.
|
|
1135
|
+
*
|
|
1136
|
+
* **Note:** this API is experimental and might change at any time. It is also not available
|
|
1137
|
+
* anymore at Manifest v3 versions of Tampermonkey 5.2+ (Chrome and derivates).
|
|
1138
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_webRequest
|
|
1022
1139
|
* @param rules An array of rules.
|
|
1023
1140
|
* @param listener A function called when the rule is triggered. It cannot impact on the rule action.
|
|
1024
1141
|
* @returns An object with an `.abort()` method.
|
|
1025
1142
|
*/
|
|
1026
1143
|
declare function GM_webRequest(
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
): Tampermonkey.AbortHandle<void
|
|
1144
|
+
rules: Tampermonkey.WebRequestRuleParam[],
|
|
1145
|
+
listener?: Tampermonkey.WebRequestListener,
|
|
1146
|
+
): Tampermonkey.AbortHandle<void>;
|
|
1030
1147
|
|
|
1031
1148
|
// GM_cookie.*
|
|
1032
1149
|
|
|
1033
1150
|
// https://stackoverflow.com/a/59987826
|
|
1034
1151
|
// for GM_cookie.delete()
|
|
1035
|
-
type AtLeastOneOf<T> = { [K in keyof T]: Pick<T, K> }[keyof T]
|
|
1152
|
+
type AtLeastOneOf<T> = { [K in keyof T]: Pick<T, K> }[keyof T];
|
|
1036
1153
|
|
|
1037
1154
|
declare var GM_cookie: {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1155
|
+
/**
|
|
1156
|
+
* Retrieves all cookies whose properties match those given.
|
|
1157
|
+
* Tampermonkey checks if the script has `@include` or `@match`
|
|
1158
|
+
* access to given `details.url` arguments!
|
|
1159
|
+
*
|
|
1160
|
+
* **Note: the `GM_cookie` API is experimental and might
|
|
1161
|
+
* return a `not supported` error at some Tampermonkey versions.**
|
|
1162
|
+
* `httpOnly` cookies are supported at the BETA versions of Tampermonkey only for now.
|
|
1163
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_cookie#api:GM_cookie.list
|
|
1164
|
+
* @param details Object containing properties of the cookies to retrieve.
|
|
1165
|
+
* @param callback Function to be called when the cookies have been retrieved.
|
|
1166
|
+
*/
|
|
1167
|
+
list(
|
|
1168
|
+
details: Tampermonkey.ListCookiesDetails,
|
|
1169
|
+
callback?: Tampermonkey.ListCookiesCallback,
|
|
1170
|
+
): void;
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Sets a cookie with the given details. Supported properties
|
|
1174
|
+
* [are defined here](https://developer.chrome.com/extensions/cookies#method-set).
|
|
1175
|
+
*
|
|
1176
|
+
* **Note: the `GM_cookie` API is experimental and might
|
|
1177
|
+
* return a `not supported` error at some Tampermonkey versions.**
|
|
1178
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_cookie#api:GM_cookie.set
|
|
1179
|
+
* @param details An object containing the details of the cookie to be set.
|
|
1180
|
+
* @param callback A function to be called when the operation is complete.
|
|
1181
|
+
*/
|
|
1182
|
+
set(
|
|
1183
|
+
details: Tampermonkey.SetCookiesDetails,
|
|
1184
|
+
callback?: Tampermonkey.ErrorCallback,
|
|
1185
|
+
): void;
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Deletes a cookie whose properties match those given.
|
|
1189
|
+
*
|
|
1190
|
+
* **Note: the `GM_cookie` API is experimental and might
|
|
1191
|
+
* return a `not supported` error at some Tampermonkey versions.**
|
|
1192
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_cookie#api:GM_cookie.delete
|
|
1193
|
+
* @param details An object containing the details of the cookie to be deleted.
|
|
1194
|
+
* @param callback Function called when the cookie has been deleted or when an error has occurred.
|
|
1195
|
+
*/
|
|
1196
|
+
delete(
|
|
1197
|
+
details: AtLeastOneOf<Tampermonkey.DeleteCookiesDetails>,
|
|
1198
|
+
callback?: Tampermonkey.ErrorCallback,
|
|
1199
|
+
): void;
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
// GM_audio.*
|
|
1203
|
+
declare var GM_audio: {
|
|
1204
|
+
/**
|
|
1205
|
+
* Sets the mute state of the current tab.
|
|
1206
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_audio#api:GM_audio.setMute
|
|
1207
|
+
* @param details An object describing the new mute state of the tab
|
|
1208
|
+
* @param callback A callback function called when the operation finishes
|
|
1209
|
+
*/
|
|
1210
|
+
setMute(
|
|
1211
|
+
details: {
|
|
1212
|
+
/** `true` to mute the tab, `false` to un‑mute it. */
|
|
1213
|
+
isMuted: boolean;
|
|
1214
|
+
},
|
|
1215
|
+
callback?: Tampermonkey.ErrorCallback,
|
|
1216
|
+
): void;
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Retrieves the current audio state of the tab.
|
|
1220
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_audio#api:GM_audio.getState
|
|
1221
|
+
* @param callback A callback function called with an object describing the tab’s audio state.
|
|
1222
|
+
*/
|
|
1223
|
+
getState(callback: Tampermonkey.AudioStateCallback): void;
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Registers a listener that is called whenever the tab's mute or audible state changes.
|
|
1227
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_audio#api:GM_audio.addStateChangeListener
|
|
1228
|
+
* @param listener A callback function called when state changes.
|
|
1229
|
+
* @param callback A callback function called once the registration attempt is complete.
|
|
1230
|
+
*/
|
|
1231
|
+
addStateChangeListener(
|
|
1232
|
+
listener: Tampermonkey.AudioStateListener,
|
|
1233
|
+
callback?: Tampermonkey.ErrorCallback,
|
|
1234
|
+
): void;
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Unregisters a previously added state‑change listener.
|
|
1238
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_audio#api:GM_audio.removeStateChangeListener
|
|
1239
|
+
* @param listener The exact listener function that was passed to `addStateChangeListener`.
|
|
1240
|
+
* @param callback A callback function called once the listener has been removed.
|
|
1241
|
+
*/
|
|
1242
|
+
removeStateChangeListener(
|
|
1243
|
+
listener: Tampermonkey.AudioStateListener,
|
|
1244
|
+
callback?: Tampermonkey.ErrorCallback,
|
|
1245
|
+
): void;
|
|
1246
|
+
};
|
|
1092
1247
|
|
|
1093
1248
|
// GM.*
|
|
1094
1249
|
|
|
@@ -1096,159 +1251,146 @@ declare var GM_cookie: {
|
|
|
1096
1251
|
* `GM` has all the `GM_*` APIs in promisified form
|
|
1097
1252
|
*/
|
|
1098
1253
|
declare var GM: Readonly<{
|
|
1099
|
-
|
|
1254
|
+
// Styles
|
|
1100
1255
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1256
|
+
/**
|
|
1257
|
+
* Adds the given style to the document and returns the injected style element.
|
|
1258
|
+
*/
|
|
1259
|
+
addStyle(css: string): Promise<HTMLStyleElement>;
|
|
1105
1260
|
|
|
1106
|
-
|
|
1261
|
+
// Storage
|
|
1107
1262
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1263
|
+
/** Sets the value of `name` to the storage */
|
|
1264
|
+
setValue(name: string, value: any): Promise<void>;
|
|
1110
1265
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1266
|
+
/** Gets the value of 'name' from storage */
|
|
1267
|
+
getValue<TValue>(name: string, defaultValue?: TValue): Promise<TValue>;
|
|
1113
1268
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1269
|
+
/** Deletes 'name' from storage */
|
|
1270
|
+
deleteValue(name: string): Promise<void>;
|
|
1116
1271
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1272
|
+
/** Lists all names of the storage */
|
|
1273
|
+
listValues(): Promise<string[]>;
|
|
1119
1274
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
name: string,
|
|
1130
|
-
listener: Tampermonkey.ValueChangeListener
|
|
1131
|
-
): Promise<number>
|
|
1275
|
+
/**
|
|
1276
|
+
* Adds a change listener to the storage and returns the listener ID.
|
|
1277
|
+
* The `remote` argument of the callback function shows whether this value was
|
|
1278
|
+
* modified from the instance of another tab (`true`) or within this script
|
|
1279
|
+
* instance (`false`). Therefore this functionality can be used by scripts of
|
|
1280
|
+
* different browser tabs to communicate with each other.
|
|
1281
|
+
* @param name Name of the observed variable
|
|
1282
|
+
*/
|
|
1283
|
+
addValueChangeListener(name: string, listener: Tampermonkey.ValueChangeListener): Promise<number>;
|
|
1132
1284
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1285
|
+
/** Removes a change listener by its ID */
|
|
1286
|
+
removeValueChangeListener(listenerId: number): Promise<void>;
|
|
1135
1287
|
|
|
1136
|
-
|
|
1288
|
+
// Resources
|
|
1137
1289
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1290
|
+
/** Get the content of a predefined `@resource` tag at the script header */
|
|
1291
|
+
getResourceText(name: string): Promise<string>;
|
|
1140
1292
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1293
|
+
/**
|
|
1294
|
+
* Get the base64 encoded URI of a predefined `@resource` tag at the script
|
|
1295
|
+
* header
|
|
1296
|
+
*/
|
|
1297
|
+
getResourceUrl(name: string): Promise<string>;
|
|
1146
1298
|
|
|
1147
|
-
|
|
1299
|
+
// Menu commands
|
|
1148
1300
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
//
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
): Promise<boolean>
|
|
1246
|
-
|
|
1247
|
-
/**
|
|
1248
|
-
* Copies data into the clipboard.
|
|
1249
|
-
* The parameter 'info' can be an object like
|
|
1250
|
-
* `{ type: 'text', mimetype: 'text/plain'}` or just a string expressing the
|
|
1251
|
-
* type ("text" or "html").
|
|
1252
|
-
*/
|
|
1253
|
-
setClipboard(data: string, info?: Tampermonkey.ContentType): Promise<void>
|
|
1254
|
-
}>
|
|
1301
|
+
/**
|
|
1302
|
+
* Register a menu to be displayed at the Tampermonkey menu at pages where this
|
|
1303
|
+
* script runs and returns a menu command ID.
|
|
1304
|
+
* @param accessKey The key to use for keyboard shortcuts
|
|
1305
|
+
*/
|
|
1306
|
+
registerMenuCommand(name: string, onClick: () => void, accessKey?: string): Promise<number>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Unregister a menu command that was previously registered by `GM_registerMenuCommand`
|
|
1309
|
+
* or `GM.registerMenuCommand` with the given menu command ID.
|
|
1310
|
+
*/
|
|
1311
|
+
unregisterMenuCommand(menuCommandId: number): Promise<void>;
|
|
1312
|
+
|
|
1313
|
+
// Requests
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Makes an xmlHttpRequest
|
|
1317
|
+
*
|
|
1318
|
+
* @throws {Tampermonkey.ErrorResponse}
|
|
1319
|
+
*/
|
|
1320
|
+
xmlHttpRequest<TContext = any>(
|
|
1321
|
+
// onload and the like still work
|
|
1322
|
+
details: Tampermonkey.Request<TContext>, // eslint-disable-line @definitelytyped/no-unnecessary-generics
|
|
1323
|
+
): Tampermonkey.PromiseWithAbort<Tampermonkey.Response<TContext>>;
|
|
1324
|
+
|
|
1325
|
+
// GM_download has two signatures, GM.download has one
|
|
1326
|
+
/**
|
|
1327
|
+
* Downloads a given URL to the local disk
|
|
1328
|
+
*
|
|
1329
|
+
* @throws {Tampermonkey.DownloadErrorResponse}
|
|
1330
|
+
*/
|
|
1331
|
+
download(details: Tampermonkey.DownloadRequest): Promise<void>;
|
|
1332
|
+
|
|
1333
|
+
// Tabs
|
|
1334
|
+
|
|
1335
|
+
/** Saves the tab object to reopen it after a page unload */
|
|
1336
|
+
saveTab(obj: any): Promise<void>;
|
|
1337
|
+
|
|
1338
|
+
/** Gets a object that is persistent as long as this tab is open */
|
|
1339
|
+
getTab(): Promise<any>;
|
|
1340
|
+
|
|
1341
|
+
/** Gets all tab objects as a hash to communicate with other script instances */
|
|
1342
|
+
getTabs(): Promise<{ [tabId: number]: any }>;
|
|
1343
|
+
|
|
1344
|
+
// Utils
|
|
1345
|
+
info: Tampermonkey.ScriptInfo;
|
|
1346
|
+
|
|
1347
|
+
/** Log a message to the console */
|
|
1348
|
+
log(...message: any[]): Promise<void>;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Opens a new tab with this url.
|
|
1352
|
+
* The options object can have the following properties:
|
|
1353
|
+
* - `active` decides whether the new tab should be focused,
|
|
1354
|
+
* - `insert` that inserts the new tab after the current one and
|
|
1355
|
+
* - `setParent` makes the browser re-focus the current tab on close.
|
|
1356
|
+
*
|
|
1357
|
+
* Otherwise the new tab is just appended.
|
|
1358
|
+
* If `options` is boolean (loadInBackground) it has the opposite meaning of
|
|
1359
|
+
* active and was added to achieve Greasemonkey 3.x compatibility.
|
|
1360
|
+
*
|
|
1361
|
+
* If neither active nor loadInBackground is given, then the tab will not be
|
|
1362
|
+
* focused.
|
|
1363
|
+
* @returns Object with the function `close`, the listener `onclose` and a flag
|
|
1364
|
+
* called `closed`.
|
|
1365
|
+
*/
|
|
1366
|
+
openInTab(url: string, options?: Tampermonkey.OpenTabOptions | boolean): Promise<Tampermonkey.OpenTabObject>;
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Shows a HTML5 Desktop notification and/or highlight the current tab.
|
|
1370
|
+
* @param ondone If specified used instead of `details.ondone`
|
|
1371
|
+
* @returns True if the notification was clicked
|
|
1372
|
+
*/
|
|
1373
|
+
notification(details: Tampermonkey.NotificationDetails, ondone?: Tampermonkey.NotificationOnDone): Promise<boolean>;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Shows a HTML5 Desktop notification and/or highlight the current tab.
|
|
1377
|
+
* @param text Text of the notification
|
|
1378
|
+
* @param title Notification title. If not specified the script name is used
|
|
1379
|
+
* @param onclick Called in case the user clicks the notification
|
|
1380
|
+
* @returns True if the notification was clicked
|
|
1381
|
+
*/
|
|
1382
|
+
notification(
|
|
1383
|
+
text: string,
|
|
1384
|
+
title?: string,
|
|
1385
|
+
image?: string,
|
|
1386
|
+
onclick?: Tampermonkey.NotificationOnClick,
|
|
1387
|
+
): Promise<boolean>;
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Copies data into the clipboard.
|
|
1391
|
+
* The parameter 'info' can be an object like
|
|
1392
|
+
* `{ type: 'text', mimetype: 'text/plain'}` or just a string expressing the
|
|
1393
|
+
* type ("text" or "html").
|
|
1394
|
+
*/
|
|
1395
|
+
setClipboard(data: string, info?: Tampermonkey.ContentType): Promise<void>;
|
|
1396
|
+
}>;
|