-
Notifications
You must be signed in to change notification settings - Fork 0
/
tampermonkey-module.d.ts
196 lines (160 loc) · 6.75 KB
/
tampermonkey-module.d.ts
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
declare var unsafeWindow : Window;
declare var GM_info : {
version : string,
scriptWillUpdate : boolean,
scriptHandler : "Tampermonkey",
scriptUpdateURL ?: string,
scriptSource : string,
scriptMetaStr ?: string,
isIncognito : boolean,
downloadMode : "native" | "disabled" | "browser",
script : {
author ?: string,
description ?: string,
excludes : string[],
homepage ?: string,
icon ?: string,
icon64 ?: string,
includes ?: string[],
lastModified : number,
matches : string[],
name : string,
namespace ?: string,
position : number,
"run-at" : string,
resources : string[],
unwrap : boolean,
version : string,
options : {
awareOfChrome : boolean,
run_at : string,
noframes ?: boolean,
compat_arrayLeft : boolean,
compat_foreach : boolean,
compat_forvarin : boolean,
compat_metadata : boolean,
compat_uW_gmonkey : boolean,
override : {
orig_excludes : string[],
orig_includes : string[],
use_includes : string[],
use_excludes : string[],
[ key : string ] : any,
},
[ key : string ] : any,
},
[ key : string ] : any,
},
[ key : string ] : any,
};
declare function GM_addStyle(css : string) : void;
declare function GM_deleteValue(name : string) : void;
declare function GM_listValues() : string[];
declare function GM_addValueChangeListener(name : string, listener : GM_Types.ValueChangeListener) : number;
declare function GM_removeValueChangeListener(listenerId : number) : void;
declare function GM_setValue(name : string, value : any) : void;
declare function GM_getValue(name : string, defaultValue ?: any) : any;
declare function GM_log(message : string) : any;
declare function GM_getResourceText(name : string) : string;
declare function GM_getResourceURL(name : string) : string;
declare function GM_registerMenuCommand(name : string, listener: Function, accessKey ?: string) : number;
declare function GM_unregisterMenuCommand(id : number) : void;
declare function GM_openInTab(url: string, options : GM_Types.OpenTabOptions) : void;
declare function GM_openInTab(url: string, loadInBackground : boolean) : void;
declare function GM_openInTab(url: string) : void;
declare function GM_xmlhttpRequest<CONTEXT_TYPE>(details : GM_Types.XHRDetails<CONTEXT_TYPE>) : GM_Types.AbortHandle<void>;
declare function GM_download(details : GM_Types.DownloadDetails) : GM_Types.AbortHandle<boolean>;
declare function GM_download(url: string, filename: string) : GM_Types.AbortHandle<boolean>;
declare function GM_getTab(callback : (obj : object) => any) : void;
declare function GM_saveTab(obj : object) : void;
declare function GM_getTabs(callback : (objs : { [ key : number ] : object }) => any) : void;
declare function GM_notification(details : GM_Types.NotificationDetails, ondone : Function) : void;
declare function GM_notification(text : string, title : string, image : string, onclick : Function) : void;
declare function GM_setClipboard(data : string, info ?: string | { type ?: string, minetype ?: string}) : void;
declare namespace GM_Types {
type ValueChangeListener = (name : string, oldValue : any, newValue : any, remote : boolean) => any;
interface OpenTabOptions {
active ?: boolean,
insert ?: boolean,
setParent ?: boolean
}
interface XHRResponse<CONTEXT_TYPE> extends Function {
DONE : 4,
HEADERS_RECEIVED : 2,
LOADING : 3,
OPENED : 1,
UNSENT : 0
context : CONTEXT_TYPE,
finalUrl : string,
readyState : 0 | 1 | 2 | 3 | 4,
responseHeaders : string,
status : number,
statusText : string,
response : any,
responseText : string,
responseXML : Document | null
}
interface XHRProgress<CONTEXT_TYPE> extends XHRResponse<CONTEXT_TYPE> {
done : number,
lengthComputable : boolean,
loaded : number,
position : number,
total : number,
totalSize : number
}
type Listener<OBJ> = (this : OBJ, event : OBJ) => any;
interface XHRDetails<CONTEXT_TYPE> {
method ?: "GET" | "HEAD" | "POST" | "PUT",
url ?: string,
headers ?: { readonly [ key : string ] : string },
data ?: string,
binary ?: boolean,
timeout ?: number,
context ?: CONTEXT_TYPE,
responseType ?: "arraybuffer" | "blob" | "json",
overrideMimeType ?: string,
anonymous ?: boolean,
fetch ?: boolean,
username ?: string,
password ?: string,
onload ?: Listener<XHRResponse<CONTEXT_TYPE>>,
onloadstart ?: Listener<XHRResponse<CONTEXT_TYPE>>,
onprogress ?: Listener<XHRProgress<CONTEXT_TYPE>>,
onreadystatechange ?: Listener<XHRResponse<CONTEXT_TYPE>>,
ontimeout ?: Listener<XHRProgress<CONTEXT_TYPE>>,
onabort ?: Listener<XHRProgress<CONTEXT_TYPE>>,
onerror ?: Listener<XHRProgress<CONTEXT_TYPE>>
}
interface AbortHandle<RETURN_TYPE> {
abort() : RETURN_TYPE
}
interface DownloadError {
error : "not_enabled" | "not_whitelisted" | "not_permitted" | "not_supported" | "not_succeeded",
details ?: string
}
interface DownloadDetails {
url : string,
name : string,
headers ?: { readonly [ key : string ] : string },
saveAs ?: boolean,
timeout ?: number,
onerror ?: Listener<DownloadError>,
ontimeout ?: Listener<object>,
onload ?: Listener<object>,
onprogress ?: Listener<XHRProgress<void>>
}
interface NotificationThis extends NotificationDetails {
id : string
}
type NotificationOnClick = (this : NotificationThis) => any;
type NotificationOnDone = (this : NotificationThis, clicked: boolean) => any;
interface NotificationDetails {
text ?: string,
title ?: string,
image ?: string,
highlight ?: boolean,
timeout ?: number
onclick ?: NotificationOnClick,
ondone ?: NotificationOnDone,
}
}