@henrikvilhelmberglund/vite-plugin-monkey 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
package/client.d.ts ADDED
@@ -0,0 +1,1085 @@
1
+ /**
2
+ * the alias of `vite-plugin-monkey/dist/client`
3
+ */
4
+ declare module "$" {
5
+ type WebRequestRule = {
6
+ selector:
7
+ | string
8
+ | {
9
+ include?: string | string[];
10
+ match?: string | string[];
11
+ exclude?: string | string[];
12
+ };
13
+ action:
14
+ | "cancel"
15
+ | {
16
+ cancel?: boolean;
17
+ redirect?:
18
+ | string
19
+ | {
20
+ from: string;
21
+ to: string;
22
+ };
23
+ };
24
+ };
25
+
26
+ type TamperScriptMeta = {
27
+ name_i18n: Record<string, string>;
28
+ description_i18n: Record<string, string>;
29
+ antifeatures: Record<string, Record<string, string>>;
30
+ blockers: unknown[];
31
+ "run-at": string;
32
+ options: object;
33
+ icon64?: string;
34
+ sync: {
35
+ imported: number;
36
+ };
37
+ webRequest?: string[];
38
+ requires: {
39
+ textContent: string;
40
+ }[];
41
+ };
42
+
43
+ type TamperInfo = {
44
+ downloadMode: "native" | "browser" | "disabled";
45
+ isIncognito: boolean;
46
+ isFirstPartyIsolation?: boolean;
47
+ scriptSource: string;
48
+ };
49
+
50
+ /**
51
+ * @see https://developer.chrome.com/docs/extensions/reference/cookies/#type-Cookie
52
+ */
53
+ type ChromeCookie = {
54
+ domain?: string;
55
+ expirationDate?: number;
56
+ httpOnly?: boolean;
57
+ name?: string;
58
+ path?: string;
59
+ sameSite?: "no_restriction" | "lax" | "strict" | "unspecified";
60
+ secure?: boolean;
61
+ storeId?: string;
62
+ url?: string;
63
+ value?: string;
64
+ };
65
+
66
+ type CbCookie = {
67
+ domain: string;
68
+ hostOnly: boolean;
69
+ httpOnly: boolean;
70
+ name: string;
71
+ path: string;
72
+ sameSite: string;
73
+ secure: boolean;
74
+ session: boolean;
75
+ value: string;
76
+ };
77
+
78
+ type CookieDetails = {
79
+ list: {
80
+ url?: string;
81
+ domain?: string;
82
+ name?: string;
83
+ path?: string;
84
+ };
85
+ set: ChromeCookie;
86
+ delete: {
87
+ name?: string;
88
+ url?: string;
89
+ };
90
+ };
91
+
92
+ type CookieCallBack = {
93
+ list: (cookies: CbCookie[], error: unknown) => void;
94
+ set: (error: unknown) => void;
95
+ delete: (error: unknown) => void;
96
+ };
97
+
98
+ type CookieResult = {
99
+ list: Promise<CbCookie[]>;
100
+ set: (error: unknown) => Promise<void>;
101
+ delete: (error: unknown) => Promise<void>;
102
+ };
103
+
104
+ type GmCookieFc = {
105
+ list: (
106
+ details: CookieDetails["list"],
107
+ callback?: CookieCallBack["list"],
108
+ ) => CookieResult["list"];
109
+ set: (
110
+ details: CookieDetails["set"],
111
+ callback?: CookieCallBack["set"],
112
+ ) => CookieResult["set"];
113
+ delete: (
114
+ details: CookieDetails["delete"],
115
+ callback?: CookieCallBack["delete"],
116
+ ) => CookieResult["delete"];
117
+ };
118
+
119
+ type WebRequestListener = (
120
+ info: "cancel" | "redirect",
121
+ message: "ok" | "error",
122
+ details: {
123
+ rule: WebRequestRule;
124
+ url: string;
125
+ redirect_url: string;
126
+ description: string;
127
+ },
128
+ ) => void;
129
+
130
+ type ViolentInfo = {
131
+ uuid: string;
132
+ injectInto: string;
133
+ platform: ViolentPlatform;
134
+ };
135
+
136
+ type ViolentPlatform = {
137
+ arch: "arm" | "mips" | "mips64" | "x86-32" | "x86-64";
138
+ browserName: string;
139
+ browserVersion: string;
140
+ os: "android" | "cros" | "linux" | "mac" | "openbsd" | "win";
141
+ };
142
+
143
+ type ViolentScriptMeta = {
144
+ excludeMatches: string[];
145
+ runAt: string;
146
+ homepageURL?: string;
147
+ license: string;
148
+ require: string[];
149
+ };
150
+
151
+ type CommonScriptMeta = {
152
+ namespace: string;
153
+ name: string;
154
+ author?: string;
155
+ description?: string;
156
+ icon?: string;
157
+ excludes: string[];
158
+ includes: string[];
159
+ matches: string[];
160
+ resources: {
161
+ name: string;
162
+ url: string;
163
+ content: string;
164
+ meta: string;
165
+ }[];
166
+ runAt: string;
167
+ version: string;
168
+ noframes: boolean;
169
+ unwrap: boolean;
170
+ homepage: string;
171
+ };
172
+
173
+ type ScriptMeta = CommonScriptMeta & TamperScriptMeta & ViolentScriptMeta;
174
+
175
+ type CommonInfo = {
176
+ version: string;
177
+ scriptHandler: string;
178
+ scriptMetaStr: string;
179
+ scriptSource: string;
180
+ scriptUpdateURL?: string;
181
+ scriptWillUpdate: boolean;
182
+ script: ScriptMeta;
183
+ };
184
+
185
+ /**
186
+ * GM_info Type
187
+ */
188
+ type GmScriptInfo = CommonInfo & TamperInfo & ViolentInfo;
189
+
190
+ type HTMLElementTagName = keyof HTMLElementTagNameMap;
191
+
192
+ type GmAddElementFc = {
193
+ <K extends HTMLElementTagName>(
194
+ tagName: K,
195
+ attributes?: Partial<HTMLElementTagNameMap[K]>,
196
+ ): HTMLElementTagNameMap[K];
197
+ (tagName: string, attributes?: Partial<HTMLElement>): HTMLElement;
198
+ <K extends HTMLElementTagName>(
199
+ parentNode: Node | Element | ShadowRoot,
200
+ tagName: K,
201
+ attributes?: Partial<HTMLElementTagNameMap[K]>,
202
+ ): HTMLElementTagNameMap[K];
203
+ (
204
+ parentNode: Node | Element | ShadowRoot,
205
+ tagName: string,
206
+ attributes?: Partial<HTMLElement>,
207
+ ): HTMLElement;
208
+ };
209
+
210
+ type GmOpenInTabDetails = {
211
+ active?: boolean;
212
+ insert?: boolean;
213
+ /**
214
+ * @available tampermonkey
215
+ */
216
+ setParent?: boolean;
217
+ /**
218
+ * @available tampermonkey
219
+ */
220
+ incognito?: boolean;
221
+ /**
222
+ * @available violentmonkey
223
+ */
224
+ container?: 0 | 1 | 2;
225
+ /**
226
+ * @available violentmonkey
227
+ */
228
+ pinned?: boolean;
229
+ };
230
+
231
+ type GmOpenHandle = {
232
+ onclose?: () => void;
233
+ closed: boolean;
234
+ close: () => void;
235
+ };
236
+
237
+ type GmOpenInTabFc = {
238
+ (url: string, details?: GmOpenInTabDetails): GmOpenHandle;
239
+ (url: string, openInBackground?: boolean): GmOpenHandle;
240
+ };
241
+
242
+ type GmNotificationDetails = {
243
+ text: string;
244
+ title?: string;
245
+ image?: string;
246
+ /**
247
+ * @available tampermonkey
248
+ */
249
+ highlight?: boolean;
250
+ /**
251
+ * @available tampermonkey
252
+ */
253
+ silent?: boolean;
254
+ /**
255
+ * @available tampermonkey
256
+ */
257
+ timeout?: number;
258
+ ondone?: () => void;
259
+ onclick?: () => void;
260
+ };
261
+
262
+ /**
263
+ * @available violentmonkey
264
+ */
265
+ type GmNotificationControl = {
266
+ /**
267
+ * @available violentmonkey
268
+ */
269
+ remove: () => Promise<void>;
270
+ };
271
+
272
+ type GmNotificationFc = {
273
+ (
274
+ text: string,
275
+ title?: string,
276
+ image?: string,
277
+ onclick?: () => void,
278
+ ): GmNotificationControl;
279
+ (
280
+ details: GmNotificationDetails,
281
+ ondone?: () => void,
282
+ ): GmNotificationControl;
283
+ };
284
+
285
+ type GmDownloadErrorEvent = {
286
+ /**
287
+ * Error reason
288
+ * - `not_enabled` - the download feature isn't enabled by the user
289
+ * - `not_whitelisted` - the requested file extension is not
290
+ * whitelisted
291
+ * - `not_permitted` - the user enabled the download feature, but did
292
+ * not give the downloads permission
293
+ * - `not_supported` - the download feature isn't supported by the
294
+ * browser/version
295
+ * - `not_succeeded` - the download wasn't started or failed, the
296
+ * details attribute may provide more information
297
+ */
298
+ error:
299
+ | "not_enabled"
300
+ | "not_whitelisted"
301
+ | "not_permitted"
302
+ | "not_supported"
303
+ | "not_succeeded";
304
+ details?: string;
305
+ };
306
+
307
+ type GmRequestEventListener<Event> = (this: Event, event: Event) => void;
308
+
309
+ type GmProgressEventBase = {
310
+ done: number;
311
+ lengthComputable: boolean;
312
+ loaded: number;
313
+ position: number;
314
+ total: number;
315
+ totalSize: number;
316
+ };
317
+
318
+ type GmDownloadProgressEvent = GmProgressEventBase & {
319
+ readonly finalUrl: string;
320
+ };
321
+
322
+ type GmDownloadRequest = {
323
+ /**
324
+ * URL from where the data should be downloaded
325
+ */
326
+ url: string;
327
+ /**
328
+ * Filename - for security reasons the file extension needs to be
329
+ * whitelisted at Tampermonkey options page
330
+ */
331
+ name: string;
332
+ headers?: Record<string, string>;
333
+ /**
334
+ * Show 'Save As' dialog
335
+ */
336
+ saveAs?: boolean;
337
+ timeout?: number;
338
+ onerror?: GmRequestEventListener<GmDownloadErrorEvent>;
339
+ ontimeout?(): void;
340
+ onload?(): void;
341
+ onprogress?: GmRequestEventListener<GmDownloadProgressEvent>;
342
+ };
343
+
344
+ type GmResponseTypeMap = {
345
+ text: string;
346
+ json: any;
347
+ arraybuffer: ArrayBuffer;
348
+ blob: Blob;
349
+ document: Document;
350
+ stream: ReadableStream<Uint8Array>;
351
+ };
352
+
353
+ type GmResponseType = keyof GmResponseTypeMap;
354
+
355
+ type GmAbortHandle<TReturn = void> = {
356
+ abort(): TReturn;
357
+ };
358
+
359
+ type GmResponseEventBase<TResponseType extends GmResponseType> = {
360
+ responseHeaders: string;
361
+ /**
362
+ * 0 = XMLHttpRequest.UNSENT
363
+ *
364
+ * 1 = XMLHttpRequest.OPENED
365
+ *
366
+ * 2 = XMLHttpRequest.HEADERS_RECEIVED
367
+ *
368
+ * 3 = XMLHttpRequest.HEADERS_RECEIVED
369
+ *
370
+ * 4 = XMLHttpRequest.DONE
371
+ */
372
+ readyState: 0 | 1 | 2 | 3 | 4;
373
+ response: GmResponseTypeMap[TResponseType];
374
+ responseText: string;
375
+ responseXML: Document | null;
376
+ status: number;
377
+ statusText: string;
378
+ };
379
+
380
+ type GmErrorEvent<TResponseType extends GmResponseType> =
381
+ GmResponseEventBase<TResponseType> & {
382
+ error: string;
383
+ };
384
+
385
+ type GmResponseEvent<
386
+ TContext,
387
+ TResponseType extends GmResponseType,
388
+ > = GmResponseEventBase<TResponseType> & {
389
+ finalUrl: string;
390
+ context: TContext;
391
+ };
392
+
393
+ type ProgressResponse<
394
+ TContext,
395
+ TResponseType extends GmResponseType,
396
+ > = GmResponseEvent<TContext, TResponseType> & GmProgressEventBase;
397
+
398
+ type GmXhrRequest<TContext, TResponseType extends GmResponseType> = {
399
+ method?: string;
400
+ url: string;
401
+ headers?: Record<string, string>;
402
+ data?:
403
+ | string
404
+ | URLSearchParams
405
+ | FormData
406
+ | ArrayBuffer
407
+ | Blob
408
+ | DataView
409
+ | ReadableStream;
410
+ /**
411
+ * @available tampermonkey
412
+ */
413
+ redirect?: `follow` | `error` | `manual`;
414
+ /**
415
+ * @available tampermonkey
416
+ */
417
+ cookie?: string;
418
+ binary?: boolean;
419
+ /**
420
+ * @available tampermonkey
421
+ */
422
+ nocache?: boolean;
423
+ /**
424
+ * @available tampermonkey
425
+ */
426
+ revalidate?: boolean;
427
+ timeout?: number;
428
+ /**
429
+ * Property which will be added to the response event object
430
+ */
431
+ context?: TContext;
432
+ /**
433
+ * @tampermonkey text, json, arraybuffer, blob, document, stream
434
+ * @violentmonkey text, json, arraybuffer, blob, document
435
+ * @default
436
+ * 'text'
437
+ */
438
+ responseType?: TResponseType;
439
+ overrideMimeType?: string;
440
+ anonymous?: boolean;
441
+ /**
442
+ * @available tampermonkey
443
+ */
444
+ fetch?: boolean;
445
+ user?: string;
446
+ password?: string;
447
+ onabort?: () => void;
448
+ onerror?: GmRequestEventListener<GmErrorEvent<TResponseType>>;
449
+ /**
450
+ * @available violentmonkey
451
+ */
452
+ onloadend?: GmRequestEventListener<
453
+ GmResponseEvent<TContext, TResponseType>
454
+ >;
455
+ onloadstart?: GmRequestEventListener<
456
+ GmResponseEvent<TContext, TResponseType>
457
+ >;
458
+ onprogress?: GmRequestEventListener<
459
+ ProgressResponse<TContext, TResponseType>
460
+ >;
461
+ onreadystatechange?: GmRequestEventListener<
462
+ GmResponseEvent<TContext, TResponseType>
463
+ >;
464
+ ontimeout?: () => void;
465
+ onload?: GmRequestEventListener<GmResponseEvent<TContext, TResponseType>>;
466
+ };
467
+
468
+ type GmXhr = {
469
+ <TContext, TResponseType extends GmResponseType = "text">(
470
+ details: GmXhrRequest<TContext, TResponseType>,
471
+ ): GmAbortHandle;
472
+ /**
473
+ * @available tampermonkey
474
+ * @see [tampermonkey#1278](https://github.com/Tampermonkey/tampermonkey/issues/1278#issuecomment-884363078)
475
+ */
476
+ RESPONSE_TYPE_STREAM?: "stream";
477
+ };
478
+
479
+ type MonkeyWindow = typeof window & {
480
+ unsafeWindow: typeof window;
481
+ /**
482
+ * @see https://www.tampermonkey.net/documentation.php#api:window.close
483
+ * @see https://violentmonkey.github.io/api/metadata-block/#grant
484
+ */
485
+ close: () => void;
486
+ /**
487
+ * @see https://www.tampermonkey.net/documentation.php#api:window.focus
488
+ * @see https://violentmonkey.github.io/api/metadata-block/#grant
489
+ */
490
+ focus: () => void;
491
+ /**
492
+ * @see https://www.tampermonkey.net/documentation.php#api:window.onurlchange
493
+ * @available tampermonkey
494
+ */
495
+ onurlchange?: null;
496
+ /**
497
+ * @see https://www.tampermonkey.net/documentation.php#api:window.onurlchange
498
+ * @available tampermonkey
499
+ */
500
+ addEventListener: (
501
+ type: "urlchange",
502
+ cb: (data: { url: string }) => void,
503
+ ) => void;
504
+ /**
505
+ * @see https://www.tampermonkey.net/documentation.php#api:window.onurlchange
506
+ * @available tampermonkey
507
+ */
508
+ removeEventListener: (
509
+ type: "urlchange",
510
+ cb: (...args: unknown[]) => unknown,
511
+ ) => void;
512
+ GM: {
513
+ addStyle: MonkeyWindow["GM_addStyle"];
514
+ addElement: MonkeyWindow["GM_addElement"];
515
+ /**
516
+ * @see https://wiki.greasespot.net/GM.registerMenuCommand
517
+ */
518
+ registerMenuCommand: MonkeyWindow["GM_registerMenuCommand"];
519
+ /**
520
+ * @see https://wiki.greasespot.net/GM.info
521
+ */
522
+ info: MonkeyWindow["GM_info"];
523
+ /**
524
+ * @available tampermonkey
525
+ */
526
+ cookie: MonkeyWindow["GM_cookie"];
527
+ /**
528
+ * @see https://wiki.greasespot.net/GM.notification
529
+ */
530
+ notification: MonkeyWindow["GM_notification"];
531
+ /**
532
+ * @see https://wiki.greasespot.net/GM.openInTab
533
+ */
534
+ openInTab: MonkeyWindow["GM_openInTab"];
535
+ /**
536
+ * @see https://wiki.greasespot.net/GM.setClipboard
537
+ */
538
+ setClipboard: MonkeyWindow["GM_setClipboard"];
539
+ /**
540
+ * @see https://wiki.greasespot.net/GM.xmlHttpRequest
541
+ */
542
+ xmlHttpRequest: MonkeyWindow["GM_xmlhttpRequest"];
543
+ /**
544
+ * @see https://wiki.greasespot.net/GM.deleteValue
545
+ */
546
+ deleteValue: (key: string) => Promise<void>;
547
+ /**
548
+ * @see https://wiki.greasespot.net/GM.getResourceUrl
549
+ */
550
+ getResourceURL: (name: string, isBlobUrl?: boolean) => Promise<string>;
551
+ /**
552
+ * @see https://wiki.greasespot.net/GM.getValue
553
+ */
554
+ getValue: <T = unknown>(key: string, defaultValue: T) => Promise<T>;
555
+ /**
556
+ * @see https://wiki.greasespot.net/GM.listValues
557
+ */
558
+ listValues: () => Promise<string[]>;
559
+ /**
560
+ * @see https://wiki.greasespot.net/GM.setValue
561
+ */
562
+ setValue: (key: string, value: unknown) => Promise<void>;
563
+ };
564
+ /**
565
+ * @see https://www.tampermonkey.net/documentation.php#GM_addElement
566
+ * @see https://violentmonkey.github.io/api/gm/#gm_addelement
567
+ */
568
+ GM_addElement: GmAddElementFc;
569
+ /**
570
+ * @see https://www.tampermonkey.net/documentation.php#GM_addStyle
571
+ * @see https://violentmonkey.github.io/api/gm/#gm_addstyle
572
+ */
573
+ GM_addStyle: (css: string) => HTMLStyleElement;
574
+ /**
575
+ * @see https://www.tampermonkey.net/documentation.php#GM_addValueChangeListener
576
+ * @see https://violentmonkey.github.io/api/gm/#gm_addvaluechangelistener
577
+ */
578
+ GM_addValueChangeListener: <T = unknown>(
579
+ name: string,
580
+ callback: (
581
+ name: string,
582
+ oldValue?: T,
583
+ newValue?: T,
584
+ remote?: boolean,
585
+ ) => void,
586
+ ) => string;
587
+ /**
588
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_cookie.list
589
+ * @see https://www.tampermonkey.net/documentation.php##api:GM_cookie.set
590
+ * @see https://www.tampermonkey.net/documentation.php##api:GM_cookie.delete
591
+ * @available tampermonkey
592
+ */
593
+ GM_cookie: GmCookieFc;
594
+ /**
595
+ * @see https://www.tampermonkey.net/documentation.php#GM_deleteValue
596
+ * @see https://violentmonkey.github.io/api/gm/#gm_deletevalue
597
+ */
598
+ GM_deleteValue: (name: string) => void;
599
+ /**
600
+ * @see https://www.tampermonkey.net/documentation.php#GM_getResourceText
601
+ * @see https://violentmonkey.github.io/api/gm/#gm_getresourcetext
602
+ */
603
+ GM_getResourceText: (name: string) => string;
604
+ /**
605
+ * @see https://www.tampermonkey.net/documentation.php#GM_getResourceURL
606
+ * @see https://violentmonkey.github.io/api/gm/#gm_getresourceurl
607
+ */
608
+ GM_getResourceURL: (name: string, isBlobUrl?: boolean) => string;
609
+ /**
610
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_getValue
611
+ * @see https://violentmonkey.github.io/api/gm/#gm_getvalue
612
+ */
613
+ GM_getValue: <T = unknown>(key: string, defaultValue?: T) => T;
614
+ /**
615
+ * @see https://www.tampermonkey.net/documentation.php#GM_getTab
616
+ * @available tampermonkey
617
+ */
618
+ GM_getTab: <T = any>(callback: (tab: T) => void) => void;
619
+ /**
620
+ * @see https://www.tampermonkey.net/documentation.php#GM_getTabs
621
+ * @available tampermonkey
622
+ */
623
+ GM_getTabs: <T = any>(
624
+ callback: (tabsMap: { [tabId: number]: T }) => void,
625
+ ) => void;
626
+ /**
627
+ * @see https://www.tampermonkey.net/documentation.php#GM_info
628
+ * @see https://violentmonkey.github.io/api/gm/#gm_info
629
+ */
630
+ GM_info: GmScriptInfo;
631
+ /**
632
+ * @see https://www.tampermonkey.net/documentation.php#GM_listValues
633
+ * @see https://violentmonkey.github.io/api/gm/#gm_listvalues
634
+ */
635
+ GM_listValues: () => string[];
636
+ /**
637
+ * @see https://www.tampermonkey.net/documentation.php#GM_log
638
+ * @available tampermonkey
639
+ */
640
+ GM_log: (...data: any[]) => void;
641
+ /**
642
+ * @see https://www.tampermonkey.net/documentation.php#GM_notification
643
+ * @see https://violentmonkey.github.io/api/gm/#gm_notification
644
+ */
645
+ GM_notification: GmNotificationFc;
646
+ /**
647
+ * @see https://www.tampermonkey.net/documentation.php#GM_openInTab
648
+ * @see https://violentmonkey.github.io/api/gm/#gm_openintab
649
+ */
650
+ GM_openInTab: GmOpenInTabFc;
651
+ /**
652
+ * @see https://www.tampermonkey.net/documentation.php#GM_registerMenuCommand
653
+ * @see https://violentmonkey.github.io/api/gm/#gm_registermenucommand
654
+ */
655
+ GM_registerMenuCommand: <T extends MouseEvent | KeyboardEvent>(
656
+ caption: string,
657
+ onClick: (event: T) => void,
658
+ accessKey?: string,
659
+ ) => string;
660
+ /**
661
+ * @see https://www.tampermonkey.net/documentation.php#GM_removeValueChangeListener
662
+ * @see https://violentmonkey.github.io/api/gm/#gm_removevaluechangelistener
663
+ */
664
+ GM_removeValueChangeListener: (listenerId: string) => void;
665
+ /**
666
+ * @see https://www.tampermonkey.net/documentation.php#GM_saveTab
667
+ * @available tampermonkey
668
+ */
669
+ GM_saveTab: (tab: unknown) => void;
670
+ /**
671
+ * @see https://www.tampermonkey.net/documentation.php#GM_setClipboard
672
+ * @see https://violentmonkey.github.io/api/gm/#gm_setclipboard
673
+ */
674
+ GM_setClipboard: (data: string, type: string) => void;
675
+ /**
676
+ * @see https://www.tampermonkey.net/documentation.php#GM_setValue
677
+ * @see https://violentmonkey.github.io/api/gm/#gm_setvalue
678
+ */
679
+ GM_setValue: (key: string, value: unknown) => void;
680
+ /**
681
+ * @see https://www.tampermonkey.net/documentation.php#GM_unregisterMenuCommand
682
+ * @see https://violentmonkey.github.io/api/gm/#gm_unregistermenucommand
683
+ */
684
+ GM_unregisterMenuCommand: (caption: string) => void;
685
+ /**
686
+ * @see https://www.tampermonkey.net/documentation.php#GM_xmlhttpRequest
687
+ * @see https://violentmonkey.github.io/api/gm/#gm_xmlhttprequest
688
+ */
689
+ GM_xmlhttpRequest: GmXhr;
690
+ /**
691
+ * @see https://www.tampermonkey.net/documentation.php#GM_download
692
+ * @see https://violentmonkey.github.io/api/gm/#gm_download
693
+ */
694
+ GM_download: {
695
+ (options: GmDownloadRequest): GmAbortHandle<boolean>;
696
+ (url: string, name?: string): GmAbortHandle<boolean>;
697
+ };
698
+ /**
699
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_webRequest
700
+ */
701
+ GM_webRequest: (
702
+ rules: WebRequestRule[],
703
+ listener: WebRequestListener,
704
+ ) => void;
705
+ };
706
+
707
+ const monkeyWindow: MonkeyWindow;
708
+
709
+ const GM: {
710
+ addStyle: (css: string) => HTMLStyleElement;
711
+ addElement: {
712
+ <K extends keyof HTMLElementTagNameMap>(
713
+ tagName: K,
714
+ attributes?: Partial<HTMLElementTagNameMap[K]> | undefined,
715
+ ): HTMLElementTagNameMap[K];
716
+ (
717
+ tagName: string,
718
+ attributes?: Partial<HTMLElement> | undefined,
719
+ ): HTMLElement;
720
+ <K_1 extends keyof HTMLElementTagNameMap>(
721
+ parentNode: Node | Element | ShadowRoot,
722
+ tagName: K_1,
723
+ attributes?: Partial<HTMLElementTagNameMap[K_1]> | undefined,
724
+ ): HTMLElementTagNameMap[K_1];
725
+ (
726
+ parentNode: Node | Element | ShadowRoot,
727
+ tagName: string,
728
+ attributes?: Partial<HTMLElement> | undefined,
729
+ ): HTMLElement;
730
+ };
731
+ registerMenuCommand: <T extends MouseEvent | KeyboardEvent>(
732
+ caption: string,
733
+ onClick: (event: T) => void,
734
+ accessKey?: string | undefined,
735
+ ) => string;
736
+ info: GmScriptInfo;
737
+ cookie: GmCookieFc;
738
+ notification: {
739
+ (
740
+ text: string,
741
+ title?: string | undefined,
742
+ image?: string | undefined,
743
+ onclick?: (() => void) | undefined,
744
+ ): {
745
+ remove: () => Promise<void>;
746
+ };
747
+ (
748
+ details: GmNotificationDetails,
749
+ ondone?: (() => void) | undefined,
750
+ ): {
751
+ remove: () => Promise<void>;
752
+ };
753
+ };
754
+ openInTab: {
755
+ (
756
+ url: string,
757
+ details?: GmOpenInTabDetails | undefined,
758
+ ): {
759
+ onclose?: (() => void) | undefined;
760
+ closed: boolean;
761
+ close: () => void;
762
+ };
763
+ (
764
+ url: string,
765
+ openInBackground?: boolean | undefined,
766
+ ): {
767
+ onclose?: (() => void) | undefined;
768
+ closed: boolean;
769
+ close: () => void;
770
+ };
771
+ };
772
+ setClipboard: (data: string, type: string) => void;
773
+ xmlHttpRequest: {
774
+ <
775
+ TContext,
776
+ TResponseType extends keyof {
777
+ text: string;
778
+ json: any;
779
+ arraybuffer: ArrayBuffer;
780
+ blob: Blob;
781
+ document: Document;
782
+ stream: ReadableStream<Uint8Array>;
783
+ } = "text",
784
+ >(
785
+ details: GmXhrRequest<TContext, TResponseType>,
786
+ ): {
787
+ abort(): void;
788
+ };
789
+ RESPONSE_TYPE_STREAM?: "stream" | undefined;
790
+ };
791
+ deleteValue: (key: string) => Promise<void>;
792
+ getResourceURL: (
793
+ name: string,
794
+ isBlobUrl?: boolean | undefined,
795
+ ) => Promise<string>;
796
+ getValue: <T = unknown>(key: string, defaultValue: T) => Promise<T>;
797
+ listValues: () => Promise<string[]>;
798
+ setValue: (key: string, value: unknown) => Promise<void>;
799
+ };
800
+
801
+ const unsafeWindow: Window & typeof globalThis;
802
+
803
+ /**
804
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_info
805
+ * @see https://violentmonkey.github.io/api/gm/#gm_info
806
+ */
807
+ const GM_info: GmScriptInfo;
808
+
809
+ /**
810
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_cookie.list
811
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_cookie.set
812
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_cookie.delete
813
+ * @available tampermonkey
814
+ */
815
+ const GM_cookie: GmCookieFc;
816
+
817
+ /**
818
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_setValue
819
+ * @see https://violentmonkey.github.io/api/gm/#gm_setvalue
820
+ */
821
+ const GM_setValue: (key: string, value: unknown) => void;
822
+
823
+ /**
824
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_deleteValue
825
+ * @see https://violentmonkey.github.io/api/gm/#gm_deletevalue
826
+ */
827
+ const GM_deleteValue: (name: string) => void;
828
+
829
+ /**
830
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_listValues
831
+ * @see https://violentmonkey.github.io/api/gm/#gm_listvalues
832
+ */
833
+ const GM_listValues: () => string[];
834
+
835
+ /**
836
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_addValueChangeListener
837
+ * @see https://violentmonkey.github.io/api/gm/#gm_addvaluechangelistener
838
+ */
839
+ const GM_addValueChangeListener: <T = unknown>(
840
+ name: string,
841
+ callback: (
842
+ name: string,
843
+ oldValue?: T | undefined,
844
+ newValue?: T | undefined,
845
+ remote?: boolean | undefined,
846
+ ) => void,
847
+ ) => string;
848
+
849
+ /**
850
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_removeValueChangeListener
851
+ * @see https://violentmonkey.github.io/api/gm/#gm_removevaluechangelistener
852
+ */
853
+ const GM_removeValueChangeListener: (listenerId: string) => void;
854
+
855
+ /**
856
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_getResourceText
857
+ * @see https://violentmonkey.github.io/api/gm/#gm_getresourcetext
858
+ */
859
+ const GM_getResourceText: (name: string) => string;
860
+
861
+ /**
862
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_getResourceURL
863
+ * @see https://violentmonkey.github.io/api/gm/#gm_getresourceurl
864
+ */
865
+ const GM_getResourceURL: (
866
+ name: string,
867
+ isBlobUrl?: boolean | undefined,
868
+ ) => string;
869
+
870
+ /**
871
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_addElement
872
+ * @see https://violentmonkey.github.io/api/gm/#gm_addelement
873
+ */
874
+ const GM_addElement: {
875
+ <K extends keyof HTMLElementTagNameMap>(
876
+ tagName: K,
877
+ attributes?: Partial<HTMLElementTagNameMap[K]> | undefined,
878
+ ): HTMLElementTagNameMap[K];
879
+ (
880
+ tagName: string,
881
+ attributes?: Partial<HTMLElement> | undefined,
882
+ ): HTMLElement;
883
+ <K_1 extends keyof HTMLElementTagNameMap>(
884
+ parentNode: Node | Element | ShadowRoot,
885
+ tagName: K_1,
886
+ attributes?: Partial<HTMLElementTagNameMap[K_1]> | undefined,
887
+ ): HTMLElementTagNameMap[K_1];
888
+ (
889
+ parentNode: Node | Element | ShadowRoot,
890
+ tagName: string,
891
+ attributes?: Partial<HTMLElement> | undefined,
892
+ ): HTMLElement;
893
+ };
894
+
895
+ /**
896
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_addStyle
897
+ * @see https://violentmonkey.github.io/api/gm/#gm_addstyle
898
+ */
899
+ const GM_addStyle: (css: string) => HTMLStyleElement;
900
+
901
+ /**
902
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_openInTab
903
+ * @see https://violentmonkey.github.io/api/gm/#gm_openintab
904
+ */
905
+ const GM_openInTab: {
906
+ (
907
+ url: string,
908
+ details?: GmOpenInTabDetails | undefined,
909
+ ): {
910
+ onclose?: (() => void) | undefined;
911
+ closed: boolean;
912
+ close: () => void;
913
+ };
914
+ (
915
+ url: string,
916
+ openInBackground?: boolean | undefined,
917
+ ): {
918
+ onclose?: (() => void) | undefined;
919
+ closed: boolean;
920
+ close: () => void;
921
+ };
922
+ };
923
+
924
+ /**
925
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_registerMenuCommand
926
+ * @see https://violentmonkey.github.io/api/gm/#gm_registermenucommand
927
+ */
928
+ const GM_registerMenuCommand: <T extends MouseEvent | KeyboardEvent>(
929
+ caption: string,
930
+ onClick: (event: T) => void,
931
+ accessKey?: string | undefined,
932
+ ) => string;
933
+
934
+ /**
935
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_unregisterMenuCommand
936
+ * @see https://violentmonkey.github.io/api/gm/#gm_unregistermenucommand
937
+ */
938
+ const GM_unregisterMenuCommand: (caption: string) => void;
939
+
940
+ /**
941
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_notification
942
+ * @see https://violentmonkey.github.io/api/gm/#gm_notification
943
+ */
944
+ const GM_notification: {
945
+ (
946
+ text: string,
947
+ title?: string | undefined,
948
+ image?: string | undefined,
949
+ onclick?: (() => void) | undefined,
950
+ ): {
951
+ remove: () => Promise<void>;
952
+ };
953
+ (
954
+ details: GmNotificationDetails,
955
+ ondone?: (() => void) | undefined,
956
+ ): {
957
+ remove: () => Promise<void>;
958
+ };
959
+ };
960
+
961
+ /**
962
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_xmlhttpRequest
963
+ * @see https://violentmonkey.github.io/api/gm/#gm_xmlhttprequest
964
+ */
965
+ const GM_xmlhttpRequest: {
966
+ <
967
+ TContext,
968
+ TResponseType extends keyof {
969
+ text: string;
970
+ json: any;
971
+ arraybuffer: ArrayBuffer;
972
+ blob: Blob;
973
+ document: Document;
974
+ stream: ReadableStream<Uint8Array>;
975
+ } = "text",
976
+ >(
977
+ details: GmXhrRequest<TContext, TResponseType>,
978
+ ): {
979
+ abort(): void;
980
+ };
981
+ RESPONSE_TYPE_STREAM?: "stream" | undefined;
982
+ };
983
+
984
+ /**
985
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_setClipboard
986
+ * @see https://violentmonkey.github.io/api/gm/#gm_setclipboard
987
+ */
988
+ const GM_setClipboard: (data: string, type: string) => void;
989
+
990
+ /**
991
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_download
992
+ * @see https://violentmonkey.github.io/api/gm/#gm_download
993
+ */
994
+ const GM_download: {
995
+ (options: GmDownloadRequest): {
996
+ abort(): boolean;
997
+ };
998
+ (
999
+ url: string,
1000
+ name?: string | undefined,
1001
+ ): {
1002
+ abort(): boolean;
1003
+ };
1004
+ };
1005
+
1006
+ /**
1007
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_log
1008
+ * @available tampermonkey
1009
+ */
1010
+ const GM_log: (...data: any[]) => void;
1011
+
1012
+ /**
1013
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_getTab
1014
+ * @available tampermonkey
1015
+ */
1016
+ const GM_getTab: <T = any>(callback: (tab: T) => void) => void;
1017
+
1018
+ /**
1019
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_saveTab
1020
+ * @available tampermonkey
1021
+ */
1022
+ const GM_saveTab: (tab: unknown) => void;
1023
+
1024
+ /**
1025
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_getTabs
1026
+ * @available tampermonkey
1027
+ */
1028
+ const GM_getTabs: <T = any>(
1029
+ callback: (tabsMap: { [tabId: number]: T }) => void,
1030
+ ) => void;
1031
+
1032
+ /**
1033
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_getValue
1034
+ * @see https://violentmonkey.github.io/api/gm/#gm_getvalue
1035
+ */
1036
+ const GM_getValue: <T = unknown>(
1037
+ key: string,
1038
+ defaultValue?: T | undefined,
1039
+ ) => T;
1040
+
1041
+ /**
1042
+ * @see https://www.tampermonkey.net/documentation.php#api:GM_webRequest
1043
+ * @available tampermonkey
1044
+ */
1045
+ const GM_webRequest: (
1046
+ rules: WebRequestRule[],
1047
+ listener: WebRequestListener,
1048
+ ) => void;
1049
+
1050
+ export {
1051
+ GM,
1052
+ GM_addElement,
1053
+ GM_addStyle,
1054
+ GM_addValueChangeListener,
1055
+ GM_cookie,
1056
+ GM_deleteValue,
1057
+ GM_download,
1058
+ GM_getResourceText,
1059
+ GM_getResourceURL,
1060
+ GM_getTab,
1061
+ GM_getTabs,
1062
+ GM_getValue,
1063
+ GM_info,
1064
+ GM_listValues,
1065
+ GM_log,
1066
+ GM_notification,
1067
+ GM_openInTab,
1068
+ GM_registerMenuCommand,
1069
+ GM_removeValueChangeListener,
1070
+ GM_saveTab,
1071
+ GM_setClipboard,
1072
+ GM_setValue,
1073
+ GM_unregisterMenuCommand,
1074
+ GM_webRequest,
1075
+ GM_xmlhttpRequest,
1076
+ type GmDownloadRequest,
1077
+ type GmNotificationDetails,
1078
+ type GmOpenInTabDetails,
1079
+ type GmScriptInfo,
1080
+ type GmXhrRequest,
1081
+ type MonkeyWindow,
1082
+ monkeyWindow,
1083
+ unsafeWindow,
1084
+ };
1085
+ }