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/types/tampermonkey.d.ts
CHANGED
|
@@ -1,567 +1,1061 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Definitions by: Steven Wang <https://github.com/silverwzw>
|
|
4
|
-
// Nikolay Borzov <https://github.com/nikolay-borzov>
|
|
5
|
-
// taozhiyu <https://github.com/taozhiyu>
|
|
6
|
-
// double-beep <https://github.com/double-beep>
|
|
7
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
1
|
+
// synced from @types/tampermonkey@5.5.0
|
|
2
|
+
// do not edit; run pnpm sync-types
|
|
8
3
|
|
|
9
4
|
// This definition is based on the API reference of Tampermonkey
|
|
10
5
|
// https://tampermonkey.net/documentation.php
|
|
11
6
|
// TypeScript Version: 3.3
|
|
12
7
|
|
|
13
8
|
declare namespace Tampermonkey {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
oldValue: any,
|
|
17
|
-
newValue: any,
|
|
18
|
-
remote: boolean
|
|
19
|
-
) => void
|
|
20
|
-
|
|
21
|
-
// Response
|
|
22
|
-
|
|
23
|
-
enum ReadyState {
|
|
24
|
-
Unsent = 0,
|
|
25
|
-
Opened = 1,
|
|
26
|
-
HeadersReceived = 2,
|
|
27
|
-
Loading = 3,
|
|
28
|
-
Done = 4
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface ResponseBase {
|
|
32
|
-
readonly responseHeaders: string
|
|
33
|
-
readonly readyState: ReadyState
|
|
34
|
-
readonly response: any
|
|
35
|
-
readonly responseText: string
|
|
36
|
-
readonly responseXML: Document | null
|
|
37
|
-
readonly status: number
|
|
38
|
-
readonly statusText: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ProgressResponseBase {
|
|
42
|
-
done: number
|
|
43
|
-
lengthComputable: boolean
|
|
44
|
-
loaded: number
|
|
45
|
-
position: number
|
|
46
|
-
total: number
|
|
47
|
-
totalSize: number
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface ErrorResponse extends ResponseBase {
|
|
51
|
-
readonly error: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface Response<TContext> extends ResponseBase {
|
|
55
|
-
readonly finalUrl: string
|
|
56
|
-
readonly context: TContext
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface ProgressResponse<TContext>
|
|
60
|
-
extends Response<TContext>,
|
|
61
|
-
ProgressResponseBase {}
|
|
62
|
-
|
|
63
|
-
// Request
|
|
64
|
-
|
|
65
|
-
interface RequestHeaders {
|
|
66
|
-
readonly [header: string]: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
type RequestEventListener<TResponse> = (
|
|
70
|
-
this: TResponse,
|
|
71
|
-
response: TResponse
|
|
72
|
-
) => void
|
|
73
|
-
|
|
74
|
-
interface Request<TContext = object> {
|
|
75
|
-
method?: 'GET' | 'HEAD' | 'POST' | undefined
|
|
76
|
-
/** Destination URL */
|
|
77
|
-
url: string
|
|
78
|
-
/**
|
|
79
|
-
* i.e. user-agent, referer... (some special headers are not supported
|
|
80
|
-
* by Safari and Android browsers)
|
|
81
|
-
*/
|
|
82
|
-
headers?: RequestHeaders | undefined
|
|
83
|
-
/** String to send via a POST request */
|
|
84
|
-
data?: string | undefined
|
|
85
|
-
/** A cookie to be patched into the sent cookie set */
|
|
86
|
-
cookie?: string | undefined
|
|
87
|
-
/** Send the data string in binary mode */
|
|
88
|
-
binary?: boolean | undefined
|
|
89
|
-
/** Don't cache the resource */
|
|
90
|
-
nocache?: boolean | undefined
|
|
91
|
-
/** Revalidate maybe cached content */
|
|
92
|
-
revalidate?: boolean | undefined
|
|
93
|
-
/** Timeout in ms */
|
|
94
|
-
timeout?: number | undefined
|
|
95
|
-
/** Property which will be added to the response object */
|
|
96
|
-
context?: TContext | undefined
|
|
97
|
-
responseType?: 'arraybuffer' | 'blob' | 'json' | undefined
|
|
98
|
-
/** MIME type for the request */
|
|
99
|
-
overrideMimeType?: string | undefined
|
|
100
|
-
/** Don't send cookies with the requests (please see the fetch notes) */
|
|
101
|
-
anonymous?: boolean | undefined
|
|
102
|
-
/**
|
|
103
|
-
* (Beta) Use a fetch instead of a xhr request(at Chrome this causes
|
|
104
|
-
* `xhr.abort`, `details.timeout` and `xhr.onprogress` to not work and
|
|
105
|
-
* makes `xhr.onreadystatechange` receive only readyState 4 events)
|
|
106
|
-
*/
|
|
107
|
-
fetch?: boolean | undefined
|
|
108
|
-
/** Username for authentication */
|
|
109
|
-
user?: string | undefined
|
|
110
|
-
password?: string | undefined
|
|
111
|
-
|
|
112
|
-
// Events
|
|
113
|
-
|
|
114
|
-
/** Callback to be executed if the request was aborted */
|
|
115
|
-
onabort?(): void
|
|
116
|
-
/** Callback to be executed if the request ended up with an error */
|
|
117
|
-
onerror?: RequestEventListener<ErrorResponse> | undefined
|
|
118
|
-
/** Callback to be executed if the request started to load */
|
|
119
|
-
onloadstart?: RequestEventListener<Response<TContext>> | undefined
|
|
120
|
-
/** Callback to be executed if the request made some progress */
|
|
121
|
-
onprogress?: RequestEventListener<ProgressResponse<TContext>> | undefined
|
|
122
|
-
/** Callback to be executed if the request's ready state changed */
|
|
123
|
-
onreadystatechange?: RequestEventListener<Response<TContext>> | undefined
|
|
124
|
-
/** Callback to be executed if the request failed due to a timeout */
|
|
125
|
-
ontimeout?(): void
|
|
126
|
-
/** Callback to be executed if the request was loaded */
|
|
127
|
-
onload?: RequestEventListener<Response<TContext>> | undefined
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Download Response
|
|
131
|
-
|
|
132
|
-
interface DownloadProgressResponse extends ProgressResponseBase {
|
|
133
|
-
readonly finalUrl: string
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface DownloadErrorResponse {
|
|
9
|
+
type StorageValue = object | string | number | boolean | undefined | null;
|
|
10
|
+
|
|
137
11
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* - `not_permitted` - the user enabled the download feature, but did
|
|
143
|
-
* not give the downloads permission
|
|
144
|
-
* - `not_supported` - the download feature isn't supported by the
|
|
145
|
-
* browser/version
|
|
146
|
-
* - `not_succeeded` - the download wasn't started or failed, the
|
|
147
|
-
* details attribute may provide more information
|
|
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.
|
|
148
16
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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,
|
|
29
|
+
}
|
|
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
|
+
|
|
164
317
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
318
|
+
* The metadata that the user can override in the settings
|
|
319
|
+
* for example run-at or excludes
|
|
167
320
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
interface OpenTabOptions {
|
|
188
|
-
/** Decides whether the new tab should be focused */
|
|
189
|
-
active?: boolean | undefined
|
|
190
|
-
/** Inserts the new tab after the current one */
|
|
191
|
-
insert?: boolean | undefined
|
|
192
|
-
/** Makes the browser re-focus the current tab on close */
|
|
193
|
-
setParent?: boolean | undefined
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
interface OpenTabObject {
|
|
197
|
-
/** Closes tab */
|
|
198
|
-
close(): void
|
|
199
|
-
/** Set closed listener */
|
|
200
|
-
onclose?(): void
|
|
201
|
-
closed: boolean
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
interface NotificationThis extends Notification {
|
|
205
|
-
id: string
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
type NotificationOnClick = (this: NotificationThis) => void
|
|
209
|
-
/** `clicked` is `true` when `text` was set */
|
|
210
|
-
type NotificationOnDone = (this: NotificationThis, clicked: boolean) => void
|
|
211
|
-
|
|
212
|
-
interface Notification {
|
|
213
|
-
/** Text of the notification (optional if highlight is set) */
|
|
214
|
-
text?: string | undefined
|
|
215
|
-
/** Notification title. If not specified the script name is used */
|
|
216
|
-
title?: string | undefined
|
|
217
|
-
image?: string | undefined
|
|
218
|
-
/** Flag whether to highlight the tab that sends the notification */
|
|
219
|
-
highlight?: boolean | undefined
|
|
220
|
-
/** Whether to play or not play a sound */
|
|
221
|
-
silent?: boolean | undefined
|
|
222
|
-
/** Time after that the notification will be hidden. `0` = disabled */
|
|
223
|
-
timeout?: number | undefined
|
|
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
|
+
|
|
224
340
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
341
|
+
* The options that the user of the userscript
|
|
342
|
+
* can set in the settings (!== overrides)
|
|
227
343
|
*/
|
|
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
|
-
orig_excludes: string[]
|
|
258
|
-
orig_includes: string[]
|
|
259
|
-
orig_matches: string[]
|
|
260
|
-
orig_noframes: string | null
|
|
261
|
-
orig_run_at: string | null
|
|
262
|
-
use_blockers: string[]
|
|
263
|
-
use_connects: string[]
|
|
264
|
-
use_excludes: string[]
|
|
265
|
-
use_includes: string[]
|
|
266
|
-
use_matches: string[]
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* The options that the user of the userscript
|
|
271
|
-
* can set in the settings (!== overrides)
|
|
272
|
-
*/
|
|
273
|
-
interface ScriptSettings {
|
|
274
|
-
check_for_updates: boolean
|
|
275
|
-
comment: string | null
|
|
276
|
-
compat_foreach: boolean
|
|
277
|
-
compat_metadata: boolean
|
|
278
|
-
compat_powerful_this: boolean | null
|
|
279
|
-
compat_prototypes: boolean
|
|
280
|
-
compat_wrappedjsobject: boolean
|
|
281
|
-
compatopts_for_requires: boolean
|
|
282
|
-
noframes: boolean | null
|
|
283
|
-
run_at: string
|
|
284
|
-
sandbox: string | null
|
|
285
|
-
tab_types: string | null
|
|
286
|
-
unwrap: boolean | null
|
|
287
|
-
|
|
288
|
-
override: ScriptMetadataOverrides
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* The resources from the metadata block (@resources)
|
|
293
|
-
* that tampermonkey should preload
|
|
294
|
-
*/
|
|
295
|
-
interface ScriptResource {
|
|
296
|
-
name: string
|
|
297
|
-
url?: string
|
|
298
|
-
content?: string
|
|
299
|
-
meta?: string
|
|
300
|
-
error?: string
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
interface WebRequestRule {
|
|
304
|
-
selector:
|
|
305
|
-
| {
|
|
306
|
-
include?: string | string[]
|
|
307
|
-
match?: string | string[]
|
|
308
|
-
exclude?: string | string[]
|
|
309
|
-
}
|
|
310
|
-
| string
|
|
311
|
-
action:
|
|
312
|
-
| string
|
|
313
|
-
| {
|
|
314
|
-
cancel?: boolean
|
|
315
|
-
redirect?:
|
|
316
|
-
| {
|
|
317
|
-
url: string
|
|
318
|
-
from?: string
|
|
319
|
-
to?: string
|
|
320
|
-
}
|
|
321
|
-
| string
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* `.. | null` means if it was not explicitely set in the metadata
|
|
327
|
-
* block it is null
|
|
328
|
-
*/
|
|
329
|
-
interface ScriptMetadata {
|
|
330
|
-
antifeatures: Record<string, Record<string, string>>
|
|
331
|
-
author: string | null
|
|
332
|
-
|
|
333
|
-
blockers: string[]
|
|
334
|
-
|
|
335
|
-
copyright: string | null
|
|
336
|
-
deleted?: number | undefined
|
|
337
|
-
description: string | null
|
|
338
|
-
description_i18n: Record<string, string> | null
|
|
339
|
-
downloadURL: string | null
|
|
340
|
-
enabled?: boolean
|
|
341
|
-
evilness: number
|
|
342
|
-
excludes: string[]
|
|
343
|
-
fileURL?: string | null
|
|
344
|
-
grant: string[]
|
|
345
|
-
header: string
|
|
346
|
-
homepage: string | null
|
|
347
|
-
icon: string | null
|
|
348
|
-
icon64: string | null
|
|
349
|
-
includes: string[]
|
|
350
|
-
lastModified: number
|
|
351
|
-
matches: string[]
|
|
352
|
-
name: string
|
|
353
|
-
name_i18n: Record<string, string> | null
|
|
354
|
-
namespace: string | null
|
|
355
|
-
options: ScriptSettings
|
|
356
|
-
|
|
357
|
-
position: number
|
|
358
|
-
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
|
+
}
|
|
359
373
|
|
|
360
374
|
/**
|
|
361
|
-
*
|
|
375
|
+
* The resources from the metadata block (@resources)
|
|
376
|
+
* that tampermonkey should preload
|
|
362
377
|
*/
|
|
363
|
-
|
|
378
|
+
interface ScriptResource {
|
|
379
|
+
name: string;
|
|
380
|
+
url?: string;
|
|
381
|
+
content?: string;
|
|
382
|
+
meta?: string;
|
|
383
|
+
error?: string;
|
|
384
|
+
}
|
|
364
385
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
+
};
|
|
368
400
|
}
|
|
369
|
-
system?: boolean | undefined
|
|
370
|
-
unwrap: boolean
|
|
371
|
-
updateURL: string | null
|
|
372
|
-
uuid: string
|
|
373
|
-
version: string
|
|
374
|
-
webRequest: WebRequestRule[] | null
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
interface ScriptInfo {
|
|
378
|
-
downloadMode: 'native' | 'browser' | 'disabled'
|
|
379
|
-
isFirstPartyIsolation?: boolean
|
|
380
|
-
isIncognito: boolean
|
|
381
|
-
script: ScriptMetadata
|
|
382
|
-
sandboxMode: 'js' | 'raw' | 'dom'
|
|
383
401
|
|
|
384
402
|
/**
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* for other managers
|
|
403
|
+
* `.. | null` means if it was not explicitely set in the metadata
|
|
404
|
+
* block it is null
|
|
388
405
|
*/
|
|
389
|
-
|
|
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[];
|
|
436
|
+
|
|
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
|
+
}
|
|
454
|
+
|
|
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";
|
|
466
|
+
|
|
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;
|
|
473
|
+
|
|
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
|
+
}
|
|
390
484
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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 | {
|
|
514
|
+
/** A RegExp to extract some parts of the URL (for example `"([^:]+)://match.me/(.*)"`). */
|
|
515
|
+
from: string;
|
|
516
|
+
/** Pattern for substitution (for example `"$1://redirected.to/$2"`). */
|
|
517
|
+
to: string;
|
|
518
|
+
};
|
|
519
|
+
};
|
|
520
|
+
}
|
|
395
521
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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;
|
|
568
|
+
}
|
|
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
|
+
};
|
|
587
|
+
}
|
|
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;
|
|
626
|
+
}
|
|
627
|
+
|
|
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
|
+
}
|
|
644
|
+
|
|
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;
|
|
657
|
+
}
|
|
399
658
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
type AudioStateListener = (
|
|
677
|
+
/** An object representing the retrieved state change. */
|
|
678
|
+
info: Tampermonkey.AudioStateListenerInfo,
|
|
679
|
+
) => void;
|
|
403
680
|
}
|
|
404
681
|
|
|
405
682
|
/**
|
|
406
|
-
* The unsafeWindow object provides full access to the pages
|
|
683
|
+
* The unsafeWindow object provides full access to the pages JavaScript
|
|
407
684
|
* functions and variables
|
|
408
685
|
*/
|
|
409
|
-
declare var unsafeWindow:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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
|
+
>;
|
|
437
720
|
|
|
438
721
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
* @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
|
|
442
724
|
*/
|
|
443
725
|
interface Window {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
type: 'urlchange',
|
|
457
|
-
listener: (urlObject: { url: string }) => void
|
|
458
|
-
): 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;
|
|
459
738
|
}
|
|
460
739
|
|
|
740
|
+
/**
|
|
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).
|
|
744
|
+
*
|
|
745
|
+
* The resulting HTML element will be attached to document head or body.
|
|
746
|
+
*
|
|
747
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_addElement
|
|
748
|
+
* @param tagName Specifies the HTML element tag name.
|
|
749
|
+
* @param attributes Attributes that applied to the HTML element.
|
|
750
|
+
* For suitable `attributes`, please consult the appropriate documentation. For example:
|
|
751
|
+
*
|
|
752
|
+
* - [`script` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
753
|
+
* - [`img` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)
|
|
754
|
+
* - [`style` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style)
|
|
755
|
+
* @returns The injected HTML element
|
|
756
|
+
*/
|
|
757
|
+
declare function GM_addElement(tagName: string, attributes: object): HTMLElement;
|
|
758
|
+
|
|
759
|
+
/**
|
|
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).
|
|
763
|
+
*
|
|
764
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_addElement
|
|
765
|
+
* @param parentNode The node the resulting HTML element will be attached to.
|
|
766
|
+
* @param tagName Specifies the HTML element tag name.
|
|
767
|
+
* @param attributes Attributes that applied to the HTML element.
|
|
768
|
+
* For suitable `attributes`, please consult the appropriate documentation. For example:
|
|
769
|
+
*
|
|
770
|
+
* - [`script` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
771
|
+
* - [`img` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)
|
|
772
|
+
* - [`style` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style)
|
|
773
|
+
*
|
|
774
|
+
* @returns The injected HTML element
|
|
775
|
+
*/
|
|
776
|
+
declare function GM_addElement(
|
|
777
|
+
parentNode: Element,
|
|
778
|
+
tagName: string,
|
|
779
|
+
attributes: object,
|
|
780
|
+
): HTMLElement;
|
|
781
|
+
|
|
461
782
|
// Styles
|
|
462
783
|
|
|
463
784
|
/**
|
|
464
|
-
*
|
|
785
|
+
* Applies the given style to the document.
|
|
786
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_addStyle
|
|
787
|
+
* @param css The styles to apply.
|
|
788
|
+
* @returns The injected style element.
|
|
465
789
|
*/
|
|
466
|
-
declare function GM_addStyle(css: string): HTMLStyleElement
|
|
790
|
+
declare function GM_addStyle(css: string): HTMLStyleElement;
|
|
467
791
|
|
|
468
792
|
// Storage
|
|
469
793
|
|
|
470
|
-
/**
|
|
471
|
-
|
|
794
|
+
/**
|
|
795
|
+
* Sets the value of a specific key in the userscript's storage.
|
|
796
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_setValue
|
|
797
|
+
* @param name A string specifying the key for which the value should be set.
|
|
798
|
+
* @param value The value to be set for the key.
|
|
799
|
+
*/
|
|
800
|
+
declare function GM_setValue(name: string, value: Tampermonkey.StorageValue): void;
|
|
472
801
|
|
|
473
802
|
/**
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* instance (`false`). Therefore this functionality can be used by scripts of
|
|
478
|
-
* different browser tabs to communicate with each other.
|
|
479
|
-
* @param name Name of the observed variable
|
|
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.
|
|
480
806
|
*/
|
|
481
|
-
declare function
|
|
482
|
-
name: string,
|
|
483
|
-
listener: Tampermonkey.ValueChangeListener
|
|
484
|
-
): number
|
|
807
|
+
declare function GM_setValues(values: Record<string, Tampermonkey.StorageValue>): void;
|
|
485
808
|
|
|
486
|
-
/**
|
|
487
|
-
|
|
809
|
+
/**
|
|
810
|
+
* Adds a listener for changes to the value of a specific key in the userscript's storage.
|
|
811
|
+
* This functionality can be used by scripts of different browser tabs to communicate with each other.
|
|
812
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_addValueChangeListener
|
|
813
|
+
* @param name A string specifying the key for which changes should be monitored.
|
|
814
|
+
* @param listener A callback function that will be called when the value of the key changes.
|
|
815
|
+
* @returns A `listenerId` value that can be used to remove the listener later using `GM_removeValueChangeListener`.
|
|
816
|
+
*/
|
|
817
|
+
declare function GM_addValueChangeListener(name: string, listener: Tampermonkey.ValueChangeListener): number;
|
|
488
818
|
|
|
489
|
-
/**
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
819
|
+
/**
|
|
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.
|
|
823
|
+
*/
|
|
824
|
+
declare function GM_removeValueChangeListener(listenerId: number): void;
|
|
494
825
|
|
|
495
|
-
/**
|
|
496
|
-
|
|
826
|
+
/**
|
|
827
|
+
* Retrieves the value of a specific key in the extension's storage.
|
|
828
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_getValue
|
|
829
|
+
* @param name A string specifying the key for which the value should be retrieved.
|
|
830
|
+
* @param defaultValue A default value to be returned if the key does not exist in the extension's storage.
|
|
831
|
+
* @returns The value of the specified key from the extension's storage, or the default value if the key does not exist.
|
|
832
|
+
*/
|
|
833
|
+
declare function GM_getValue<TValue>(name: string, defaultValue?: TValue): TValue;
|
|
497
834
|
|
|
498
|
-
/**
|
|
499
|
-
|
|
835
|
+
/**
|
|
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.
|
|
842
|
+
*/
|
|
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;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Returns a list of keys of all stored data.
|
|
876
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_values#api:GM_listValues
|
|
877
|
+
*/
|
|
878
|
+
declare function GM_listValues(): string[];
|
|
500
879
|
|
|
501
880
|
// Resources
|
|
502
881
|
|
|
503
|
-
/**
|
|
504
|
-
|
|
882
|
+
/**
|
|
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
|
|
886
|
+
* @param name The name of the resource to retrieve.
|
|
887
|
+
* @returns The text of the resource as a string.
|
|
888
|
+
*/
|
|
889
|
+
declare function GM_getResourceText(name: string): string;
|
|
505
890
|
|
|
506
891
|
/**
|
|
507
|
-
*
|
|
508
|
-
* header
|
|
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
|
|
895
|
+
* @param name The name of the resource to retrieve.
|
|
896
|
+
* @returns The URL of the resource as a string.
|
|
509
897
|
*/
|
|
510
|
-
declare function GM_getResourceURL(name: string): string
|
|
898
|
+
declare function GM_getResourceURL(name: string): string;
|
|
511
899
|
|
|
512
900
|
// Menu commands
|
|
513
901
|
|
|
514
902
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
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
|
|
907
|
+
* @param name A string containing the text to display for the menu item.
|
|
908
|
+
* @param onclick A function to be called when the menu item is selected.
|
|
909
|
+
* The function will be passed a single parameter,
|
|
910
|
+
* which is the currently active tab. As of Tampermonkey 4.14,
|
|
911
|
+
* a `MouseEvent` or `KeyboardEvent` is passed as function argument.
|
|
912
|
+
* @param optionsOrAccessKey An access key or options to customize the menu item.
|
|
913
|
+
* @returns A menu entry ID that can be used to unregister the command.
|
|
517
914
|
*/
|
|
518
915
|
declare function GM_registerMenuCommand(
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
)
|
|
916
|
+
name: string,
|
|
917
|
+
onClick: (
|
|
918
|
+
event: MouseEvent | KeyboardEvent,
|
|
919
|
+
) => void,
|
|
920
|
+
optionsOrAccessKey?: string | {
|
|
921
|
+
/**
|
|
922
|
+
* An optional number that was returned by a previous `GM_registerMenuCommand` call.
|
|
923
|
+
* If specified, the according menu item will be updated with the new options.
|
|
924
|
+
* If not specified or the menu item can't be found, a new menu item will be created.
|
|
925
|
+
*/
|
|
926
|
+
id?: number | string;
|
|
927
|
+
/**
|
|
928
|
+
* An optional access key for the menu item. This can be used to create a shortcut for the menu item.
|
|
929
|
+
* For example, if the access key is "s", the user can select the menu item by pressing "s"
|
|
930
|
+
* when Tampermonkey's popup-menu is open. Please note that there are browser-wide shortcuts
|
|
931
|
+
* configurable to open Tampermonkey's popup-menu (`chrome://extensions/shortcuts` in Chrome,
|
|
932
|
+
* `about:addons` + "Manage Extension Shortcuts" in Firefox)
|
|
933
|
+
*/
|
|
934
|
+
accessKey?: string;
|
|
935
|
+
/**
|
|
936
|
+
* An optional boolean parameter that specifies whether the popup menu should be closed
|
|
937
|
+
* after the menu item is clicked. The default value is `true`. Please note that this setting
|
|
938
|
+
* has no effect on the menu command section that is added to the page's context menu.
|
|
939
|
+
*/
|
|
940
|
+
autoClose?: boolean;
|
|
941
|
+
/**
|
|
942
|
+
* An optional string that specifies the title of the menu item. This is displayed
|
|
943
|
+
* as a tooltip when the user hovers the mouse over the menu item.
|
|
944
|
+
*/
|
|
945
|
+
title?: string;
|
|
946
|
+
},
|
|
947
|
+
): number;
|
|
523
948
|
|
|
524
949
|
/**
|
|
525
|
-
*
|
|
526
|
-
* `GM_registerMenuCommand` or `GM.registerMenuCommand`
|
|
950
|
+
* Removes an existing entry from the userscript's menu in the browser
|
|
951
|
+
* that was previously registered by `GM_registerMenuCommand` or `GM.registerMenuCommand`
|
|
952
|
+
* with the given menu command ID.
|
|
953
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_registerMenuCommand#api:GM_unregisterMenuCommand
|
|
954
|
+
* @param menuCommandId The id of the menu item to remove.
|
|
527
955
|
*/
|
|
528
|
-
declare function GM_unregisterMenuCommand(menuCommandId: number): void
|
|
956
|
+
declare function GM_unregisterMenuCommand(menuCommandId: number): void;
|
|
529
957
|
|
|
530
958
|
// Requests
|
|
531
959
|
|
|
532
|
-
/**
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
960
|
+
/**
|
|
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
|
|
979
|
+
* @param details An object containing the details of the request to be sent
|
|
980
|
+
* and the callback functions to be called when the response is received.
|
|
981
|
+
*/
|
|
982
|
+
declare function GM_xmlhttpRequest<TContext = any>( // eslint-disable-line @definitelytyped/no-unnecessary-generics
|
|
983
|
+
details: Tampermonkey.Request<TContext>,
|
|
984
|
+
): Tampermonkey.AbortHandle<void>;
|
|
536
985
|
|
|
537
|
-
/**
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
986
|
+
/**
|
|
987
|
+
* Downloads a file from a specified URL and saves it to the user's local machine.
|
|
988
|
+
* Note: The browser might modify the desired filename. Especially a file extension might
|
|
989
|
+
* be added if the browser finds this to be safe to download at the current OS.
|
|
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
|
|
994
|
+
* @param details Details about the download.
|
|
995
|
+
*/
|
|
996
|
+
declare function GM_download(details: Tampermonkey.DownloadRequest): Tampermonkey.AbortHandle<boolean>;
|
|
997
|
+
/**
|
|
998
|
+
* Downloads a file from a specified URL and saves it to the user's local machine.
|
|
999
|
+
* Note: The browser might modify the desired filename. Especially a file extension might
|
|
1000
|
+
* be added if the browser finds this to be safe to download at the current OS.
|
|
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.
|
|
1007
|
+
* @param name The name to use for the downloaded file. This should include the file's extension,
|
|
1008
|
+
* such as `.txt` or `.pdf`. For security reasons the file extension needs to be whitelisted
|
|
1009
|
+
* at Tampermonkey's options page
|
|
1010
|
+
*/
|
|
1011
|
+
declare function GM_download(url: string | File | Blob, name: string): Tampermonkey.AbortHandle<boolean>;
|
|
545
1012
|
|
|
546
1013
|
// Tabs
|
|
547
1014
|
|
|
548
|
-
/**
|
|
549
|
-
|
|
1015
|
+
/**
|
|
1016
|
+
* Saves information about a tab so that it can be retrieved later
|
|
1017
|
+
* using the `GM_getTab` function.
|
|
1018
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_tabs#api:GM_saveTab
|
|
1019
|
+
* @param tab An object containing the information to be saved about the tab.
|
|
1020
|
+
* @param callback An optional callback function
|
|
1021
|
+
*/
|
|
1022
|
+
declare function GM_saveTab(tab: object, callback?: () => void): void;
|
|
550
1023
|
|
|
551
|
-
/**
|
|
552
|
-
|
|
1024
|
+
/**
|
|
1025
|
+
* Gets a object that is persistent as long as this tab is open
|
|
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.
|
|
1028
|
+
*/
|
|
1029
|
+
declare function GM_getTab(callback: (obj: any) => void): void;
|
|
553
1030
|
|
|
554
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* Gets all tab objects as a hash to communicate with other script instances
|
|
1033
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_tabs#api:GM_getTabs
|
|
1034
|
+
* @param callback A callback function that will be called with the information about the tabs..
|
|
1035
|
+
*/
|
|
555
1036
|
declare function GM_getTabs(
|
|
556
|
-
|
|
557
|
-
|
|
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;
|
|
558
1045
|
|
|
559
1046
|
// Utils
|
|
560
1047
|
|
|
561
|
-
|
|
1048
|
+
/**
|
|
1049
|
+
* Returns information about the script and Tampermonkey.
|
|
1050
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_info
|
|
1051
|
+
*/
|
|
1052
|
+
declare var GM_info: Tampermonkey.ScriptInfo;
|
|
562
1053
|
|
|
563
|
-
/**
|
|
564
|
-
|
|
1054
|
+
/**
|
|
1055
|
+
* Logs a message to the console
|
|
1056
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_log
|
|
1057
|
+
*/
|
|
1058
|
+
declare function GM_log(...message: any[]): void;
|
|
565
1059
|
|
|
566
1060
|
/**
|
|
567
1061
|
* Opens a new tab with this url.
|
|
@@ -571,211 +1065,332 @@ declare function GM_log(...message: any[]): void
|
|
|
571
1065
|
* - `setParent` makes the browser re-focus the current tab on close.
|
|
572
1066
|
*
|
|
573
1067
|
* Otherwise the new tab is just appended.
|
|
574
|
-
* If `options` is boolean (loadInBackground) it has the opposite meaning of
|
|
1068
|
+
* If `options` is boolean (`loadInBackground`) it has the opposite meaning of
|
|
575
1069
|
* active and was added to achieve Greasemonkey 3.x compatibility.
|
|
576
1070
|
*
|
|
577
|
-
* If neither active nor loadInBackground is given, then the tab will not be
|
|
1071
|
+
* If neither `active` nor `loadInBackground` is given, then the tab will not be
|
|
578
1072
|
* focused.
|
|
579
|
-
* @
|
|
1073
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_openInTab
|
|
1074
|
+
* @param url The URL of the page to open in the new tab.
|
|
1075
|
+
* @param options An object that can be used to customize the behavior of the new tab.
|
|
1076
|
+
* @returns An object with the function `close`, the listener `onclose` and a flag
|
|
580
1077
|
* called `closed`.
|
|
581
1078
|
*/
|
|
582
1079
|
declare function GM_openInTab(
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
): Tampermonkey.OpenTabObject
|
|
1080
|
+
url: string,
|
|
1081
|
+
options?: Tampermonkey.OpenTabOptions | boolean,
|
|
1082
|
+
): Tampermonkey.OpenTabObject;
|
|
586
1083
|
|
|
587
1084
|
/**
|
|
588
|
-
* Shows
|
|
589
|
-
*
|
|
1085
|
+
* Shows an HTML5 Desktop notification and/or highlight the current tab
|
|
1086
|
+
* using a provided message and other optional parameters.
|
|
1087
|
+
*
|
|
1088
|
+
* Since v5.0, if no `url` and no `tag` is provided in `details` argument, the notification will close
|
|
1089
|
+
* when the userscript unloads (e.g. when the page is reloaded or the tab is closed).
|
|
1090
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_notification
|
|
1091
|
+
* @param details Notification parameters.
|
|
1092
|
+
* @param ondone A callback function that will be called when the notification is closed
|
|
1093
|
+
* (no matter if this was triggered by a timeout or a click) or the tab was highlighted.
|
|
1094
|
+
* If specified, used instead of `details.ondone`.
|
|
590
1095
|
*/
|
|
591
1096
|
declare function GM_notification(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
): void
|
|
1097
|
+
details: Tampermonkey.NotificationDetails,
|
|
1098
|
+
ondone?: Tampermonkey.NotificationOnDone,
|
|
1099
|
+
): void;
|
|
595
1100
|
|
|
596
1101
|
/**
|
|
597
|
-
* Shows
|
|
598
|
-
*
|
|
599
|
-
* @
|
|
600
|
-
* @param
|
|
1102
|
+
* Shows an HTML5 Desktop notification and/or highlight the current tab
|
|
1103
|
+
* using a provided message and other optional parameters.
|
|
1104
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_notification
|
|
1105
|
+
* @param text A string containing the message to display in the notification.
|
|
1106
|
+
* @param title The title of the notification. If not specified, the script name is used.
|
|
1107
|
+
* @param image The URL of an image to display in the notification.
|
|
1108
|
+
* @param onClick A callback function that will be called when the user clicks on the notification.
|
|
601
1109
|
*/
|
|
602
1110
|
declare function GM_notification(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
): void
|
|
1111
|
+
text: string,
|
|
1112
|
+
title?: string,
|
|
1113
|
+
image?: string,
|
|
1114
|
+
onClick?: Tampermonkey.NotificationOnClick,
|
|
1115
|
+
): void;
|
|
608
1116
|
|
|
609
1117
|
/**
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
* type
|
|
1118
|
+
* Sets the text of the clipboard to a specified value.
|
|
1119
|
+
* @url https://www.tampermonkey.net/documentation.php?q=GM_setClipboard
|
|
1120
|
+
* @param data The string to set as the clipboard text.
|
|
1121
|
+
* @param info A string expressing the type `text` or `html` or an object
|
|
1122
|
+
* like `{ type: 'text', mimetype: 'text/plain'}`.
|
|
1123
|
+
* @param callback An optional callback function that is called when the clipboard has been set.
|
|
614
1124
|
*/
|
|
615
1125
|
declare function GM_setClipboard(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
)
|
|
1126
|
+
data: string,
|
|
1127
|
+
info?: Tampermonkey.ContentType,
|
|
1128
|
+
callback?: () => void,
|
|
1129
|
+
): void;
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
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
|
|
1139
|
+
* @param rules An array of rules.
|
|
1140
|
+
* @param listener A function called when the rule is triggered. It cannot impact on the rule action.
|
|
1141
|
+
* @returns An object with an `.abort()` method.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function GM_webRequest(
|
|
1144
|
+
rules: Tampermonkey.WebRequestRuleParam[],
|
|
1145
|
+
listener?: Tampermonkey.WebRequestListener,
|
|
1146
|
+
): Tampermonkey.AbortHandle<void>;
|
|
1147
|
+
|
|
1148
|
+
// GM_cookie.*
|
|
1149
|
+
|
|
1150
|
+
// https://stackoverflow.com/a/59987826
|
|
1151
|
+
// for GM_cookie.delete()
|
|
1152
|
+
type AtLeastOneOf<T> = { [K in keyof T]: Pick<T, K> }[keyof T];
|
|
1153
|
+
|
|
1154
|
+
declare var GM_cookie: {
|
|
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
|
+
};
|
|
619
1247
|
|
|
620
1248
|
// GM.*
|
|
621
1249
|
|
|
622
1250
|
/**
|
|
623
|
-
* `GM` has all the `GM_*`
|
|
1251
|
+
* `GM` has all the `GM_*` APIs in promisified form
|
|
624
1252
|
*/
|
|
625
1253
|
declare var GM: Readonly<{
|
|
626
|
-
|
|
1254
|
+
// Styles
|
|
627
1255
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
1256
|
+
/**
|
|
1257
|
+
* Adds the given style to the document and returns the injected style element.
|
|
1258
|
+
*/
|
|
1259
|
+
addStyle(css: string): Promise<HTMLStyleElement>;
|
|
632
1260
|
|
|
633
|
-
|
|
1261
|
+
// Storage
|
|
634
1262
|
|
|
635
|
-
|
|
636
|
-
|
|
1263
|
+
/** Sets the value of `name` to the storage */
|
|
1264
|
+
setValue(name: string, value: any): Promise<void>;
|
|
637
1265
|
|
|
638
|
-
|
|
639
|
-
|
|
1266
|
+
/** Gets the value of 'name' from storage */
|
|
1267
|
+
getValue<TValue>(name: string, defaultValue?: TValue): Promise<TValue>;
|
|
640
1268
|
|
|
641
|
-
|
|
642
|
-
|
|
1269
|
+
/** Deletes 'name' from storage */
|
|
1270
|
+
deleteValue(name: string): Promise<void>;
|
|
643
1271
|
|
|
644
|
-
|
|
645
|
-
|
|
1272
|
+
/** Lists all names of the storage */
|
|
1273
|
+
listValues(): Promise<string[]>;
|
|
646
1274
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
name: string,
|
|
657
|
-
listener: Tampermonkey.ValueChangeListener
|
|
658
|
-
): 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>;
|
|
659
1284
|
|
|
660
|
-
|
|
661
|
-
|
|
1285
|
+
/** Removes a change listener by its ID */
|
|
1286
|
+
removeValueChangeListener(listenerId: number): Promise<void>;
|
|
662
1287
|
|
|
663
|
-
|
|
1288
|
+
// Resources
|
|
664
1289
|
|
|
665
|
-
|
|
666
|
-
|
|
1290
|
+
/** Get the content of a predefined `@resource` tag at the script header */
|
|
1291
|
+
getResourceText(name: string): Promise<string>;
|
|
667
1292
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1293
|
+
/**
|
|
1294
|
+
* Get the base64 encoded URI of a predefined `@resource` tag at the script
|
|
1295
|
+
* header
|
|
1296
|
+
*/
|
|
1297
|
+
getResourceUrl(name: string): Promise<string>;
|
|
673
1298
|
|
|
674
|
-
|
|
1299
|
+
// Menu commands
|
|
675
1300
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
//
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
): Promise<boolean>
|
|
773
|
-
|
|
774
|
-
/**
|
|
775
|
-
* Copies data into the clipboard.
|
|
776
|
-
* The parameter 'info' can be an object like
|
|
777
|
-
* `{ type: 'text', mimetype: 'text/plain'}` or just a string expressing the
|
|
778
|
-
* type ("text" or "html").
|
|
779
|
-
*/
|
|
780
|
-
setClipboard(data: string, info?: Tampermonkey.ContentType): Promise<void>
|
|
781
|
-
}>
|
|
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
|
+
}>;
|