forked from magicoflolis/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserJS.d.ts
More file actions
145 lines (131 loc) 路 4.5 KB
/
Copy pathUserJS.d.ts
File metadata and controls
145 lines (131 loc) 路 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// import GM from '@types/greasemonkey';
// import '@types/tampermonkey';
import '@violentmonkey/types';
import { type GSForkQuery } from './types';
/**
* Some sites will alter or remove document functions
* To get around this we bind them to the `userjs` object
*
* This method is based on uBlock Origin `scriptlets.js` file
*
* [Source Code](https://github.com/gorhill/uBlock/blob/master/assets/resources/scriptlets.js)
*/
export declare function safeSelf(): {
XMLHttpRequest: typeof XMLHttpRequest;
createElement: typeof document.createElement;
createElementNS: typeof document.createElementNS;
createTextNode: typeof document.createTextNode;
setTimeout: typeof setTimeout;
clearTimeout: typeof clearTimeout;
};
export declare function loadCSS(css: string, name: string): HTMLStyleElement | undefined;
export declare function observe<E extends Node>(
element: E,
listener: MutationCallback,
options: MutationObserverInit
): MutationObserver;
/**
* Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method.
* @param url Specifies a MIME type for the document.
*
* [Violentmonkey Reference](https://violentmonkey.github.io/api/gm/#gm_openintab)
*
* [Greasespot Reference](https://wiki.greasespot.net/GM.openInTab)
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/open)
*/
export declare function openTab(url: string | URL): WindowProxy | null;
/**
* Get information about the current userscript.
*
* [ViolentMonkey Reference](https://violentmonkey.github.io/api/gm/#gm_info)
*/
export declare function getGMInfo(): typeof GM_info;
export interface StorageSystem {
prefix: string;
/**
* Alias of `window.localStorage.getItem`
*/
getItem<K extends string>(key: K): string | null;
has<K extends string>(key: K): boolean;
/**
* Alias of `window.localStorage.setItem`
*/
setItem<K extends string, V extends string>(key: K, value: V): void;
/**
* Alias of `window.localStorage.removeItem`
*/
remove<K extends string>(key: K): void;
/**
* Set value - Saves key to either GM managed storage or `window.localStorage`
*
* [ViolentMonkey Reference](https://violentmonkey.github.io/api/gm/#gm_setvalue)
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API)
*/
setValue<K extends string, V>(key: K, v: V): Promise<void>;
/**
* Get value
*
* [ViolentMonkey Reference](https://violentmonkey.github.io/api/gm/#gm_getvalue)
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API)
*/
getValue<K extends string, D>(key: K, def?: D): Promise<D>;
}
export interface Network {
/**
* Fetch a URL with fetch API as fallback
*
* When GM is supported, makes a request like XMLHttpRequest, with some special capabilities, not restricted by same-origin policy
*
* [ViolentMonkey Reference](https://violentmonkey.github.io/api/gm/#gm_xmlhttprequest)
*
* [XMLHttpRequest MDN Reference](https://developer.mozilla.org/docs/Web/API/XMLHttpRequest)
*
* [Fetch MDN Reference](https://developer.mozilla.org/docs/Web/API/Fetch_API)
*/
req<T = string | Blob | ArrayBuffer | Document | object | Response>(
url: RequestInfo | URL,
method: Request['method'],
responseType: VMScriptResponseType,
data: VMScriptGMXHRDetails<T> | RequestInit,
useFetch: boolean
): Promise<T>;
format(bytes: number, decimals: number): string;
sizes: string[];
xmlRequest<T = string | Blob | ArrayBuffer | Document | object | Response>(
details: VMScriptGMXHRDetails<T> | RequestInit
): Promise<T | typeof GM_xmlhttpRequest<T>>;
bscStr<S extends string>(str: S, lowerCase: boolean): S;
}
declare class Timeout {
public ids: number[];
public set(delay: number, reason: any): Promise<any>;
public clear(...ids: number[]): void;
}
export interface Container {
webpage: URL;
host: string;
domain: string;
ready: boolean;
injected: boolean;
shadowRoot?: ShadowRoot | HTMLElement;
supported: boolean;
frame: HTMLElement | HTMLIFrameElement;
cache: Map<string, {
[engine: string]: GSForkQuery[];
}>;
userjsCache: Map<number, GSForkQuery[]>;
root: HTMLElement;
unsaved: boolean;
isBlacklisted: boolean;
rebuild: boolean;
counters: {
total: number;
[engine: string]: number;
};
opacityMin: string;
opacityMax: string;
Timeout: new () => Timeout;
}