-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser.d.ts
1451 lines (1451 loc) · 60.8 KB
/
browser.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** Copyright 2021 _y_s */
/** @type integer */
type integer = number
declare namespace browser {
namespace alarms {
type Alarm = {
name: string
scheduledTime: number
periodInMinutes?: number
}
function clear(name?: string): Promise<boolean>
function clearAll(): Promise<boolean>
function create(name?: string, alarmInfo?: { when?: number, delayInMinutes?: number, periodInMinutes?: number }): Promise<void>
function get(name?: string): Promise<Alarm | undefined>
function getAll(): Promise<Alarm[]>
const onAlarm: events.Event<[alarm: Alarm]>
}
namespace bookmarks {
type BookmarkTreeNode = {
children?: BookmarkTreeNode[]
dateAdded?: number
dateGroupModified?: number
id: string
index?: integer
parentId?: string
title: string
type?: BookmarkTreeNodeType
unmodifiable?: BookmarkTreeNodeUnmodifiable
url?: string
}
type BookmarkTreeNodeType = "bookmark" | "folder" | "separator"
type BookmarkTreeNodeUnmodifiable = "managed"
type CreateDetails = {
index?: integer
parentId?: string
title?: string
type?: BookmarkTreeNodeType
url?: string
}
function create(bookmark: CreateDetails): Promise<BookmarkTreeNode>
function get(idOrIdList: string | string[]): Promise<BookmarkTreeNode>
function getChildren(id: string): Promise<BookmarkTreeNode>
function getRecent(numberOfItems: integer): Promise<BookmarkTreeNode>
function getSubTree(id: string): Promise<BookmarkTreeNode>
function getTree(): Promise<BookmarkTreeNode>
function move(id: string, destination: { parentId?: string, index?: integer }): Promise<BookmarkTreeNode>
function remove(id: string): Promise<void>
function removeTree(id: string): Promise<void>
function search(query: string | { query?: string, url?: string, title?: string }): Promise<BookmarkTreeNode[]>
function update(id: string, change: { title?: string, url?: string }): Promise<BookmarkTreeNode>
const onCreated: events.Event<[id: string, bookmark: BookmarkTreeNode]>
const onRemoved: events.Event<[id: string, removeInfo: { parentId: string, index: integer, node: BookmarkTreeNode }]>
const onChanged: events.Event<[id: string, changeInfo: { title: string, url?: string }]>
const onMoved: events.Event<[id: string, moveInfo: { parentId: string, index: integer, oldParentId: string, oldIndex: integer }]>
const onChildrenReordered: events.Event<[id: string, reorderInfo: { childIds: string[] }]>
const onImportBegan: events.Event
const onImportEnded: events.Event
}
namespace browserAction {
type ColorArray = [red: integer, green: integer, blue: integer, alpha: integer]
type ImageDataType = ImageData
function setTitle(details: { title: string | null, tabId?: integer, windowId?: integer }): Promise<void>
function getTitle(details: { tabId?: integer, windowId?: integer }): Promise<string>
function setIcon(details: {
imageData?: ImageDataType | { [key: number]: ImageDataType }
path?: string | { [key: number]: string }
tabId?: integer
windowId?: integer
}): Promise<void>
function setPopup(details: { tabId?: integer, windowId?: integer, popup: string | null }): Promise<void>
function getPopup(details: { tabId?: integer, windowId?: integer }): Promise<string>
function openPopup(): Promise<void>
function setBadgeText(details: { text: string | null, tabId?: integer, windowId?: integer }): Promise<void>
function getBadgeText(details: { tabId?: integer, windowId?: integer }): Promise<string>
function setBadgeBackgroundColor(details: { color: string | ColorArray | null, tabId?: integer, windowId?: integer }): Promise<void>
function getBadgeBackgroundColor(details: { tabId?: integer, windowId?: integer }): Promise<ColorArray>
function setBadgeTextColor(details: { color: string | ColorArray | null, tabId?: integer, windowId?: integer }): Promise<void>
function getBadgeTextColor(details: { tabId?: integer, windowId?: integer }): Promise<ColorArray>
function enable(tabId?: integer): Promise<void>
function disable(tabId?: integer): Promise<void>
function isEnabled(details: { tabId?: integer, windowId?: integer }): Promise<boolean>
const onClicked: events.Event<[
tab: tabs.Tab,
OnClickData: { modifiers: ("Shift" | "Alt" | "Command" | "Ctrl" | "MacCtrl")[], button: number }
]>
}
namespace browserSettings {
const allowPopupsForUserEvents: types.BrowserSetting<boolean> // Firefox 57+
const cacheEnabled: types.BrowserSetting<boolean> // Firefox 56+
const closeTabsByDoubleClick: types.BrowserSetting<boolean> // Firefox 61+ (w/o Android)
const contextMenuShowEvent: types.BrowserSetting<"mouseup" | "mousedown"> // Firefox 59+
const ftpProtocolEnabled: types.BrowserSetting<boolean> // Firefox 72+ (ro: 88+)
const homepageOverride: types.BrowserSetting<string> // Firefox 57+ (ro)
const imageAnimationBehavior: types.BrowserSetting<"normal" | "none" | "once"> // Firefox 57+
const newTabPageOverride: types.BrowserSetting<string> // Firefox 57+ (ro)
const newTabPosition: types.BrowserSetting<"afterCurrent" | "relatedAfterCurrent" | "atEnd"> // Firefox 61+
const openBookmarksInNewTabs: types.BrowserSetting<boolean> // Firefox 59+
const openSearchResultsInNewTabs: types.BrowserSetting<boolean> // Firefox 59+
const openUrlbarResultsInNewTabs: types.BrowserSetting<boolean> // Firefox 61+
const overrideDocumentColors: types.BrowserSetting<"high-contrast-only" | "never" | "always" > // Firefox 61+
const useDocumentFonts: types.BrowserSetting<boolean> // Firefox 61+
const webNotificationsDisabled: types.BrowserSetting<boolean>; // Firefox 58+
const zoomFullPage: types.BrowserSetting<boolean> // Firefox 75+ (w/o Android)
const zoomSiteSpecific: types.BrowserSetting<boolean> // Firefox 75+ (w/o Android)
}
namespace browsingData {
type DataTypeSet = {
cache?: boolean
cookies?: boolean
downloads?: boolean
fileSystems?: boolean
formData?: boolean
history?: boolean
indexedDB?: boolean
localStorage?: boolean
passwords?: boolean
pluginData?: boolean
serverBoundCertificates?: boolean
serviceWorkers?: boolean
}
type RemovalOptions = {
cookieStoreId?: string
hostnames?: string[]
originTypes?: { unprotectedWeb?: boolean, protectedWeb?: boolean, extension?: boolean }
since?: number
}
function remove(removalOptions: RemovalOptions, dataTypes: DataTypeSet): Promise<void>
function removeCache(removalOptions?: RemovalOptions): Promise<void>
function removeCookies(removalOptions: RemovalOptions): Promise<void>
function removeDownloads(removalOptions: RemovalOptions): Promise<void>
function removeFormData(removalOptions: RemovalOptions): Promise<void>
function removeHistory(removalOptions: RemovalOptions): Promise<void>
function removeLocalStorage(removalOptions: RemovalOptions): Promise<void>
function removePasswords(removalOptions: RemovalOptions): Promise<void>
function removePluginData(removalOptions: RemovalOptions): Promise<void>
function settings(): Promise<{ options: RemovalOptions, dataToRemove: DataTypeSet, dataRemovalPermitted: DataTypeSet }>
}
namespace captivePortal {
const canonicalURL: string
function getLastChecked(): Promise<integer>
function getState(): Promise<"unknown" | "not_captive" | "unlocked_portal" | "locked_portal">
const onConnectivityAvailable: events.Event<[status: "captive" | "clear"]>
const onStateChanged: events.Event<[status: "unknown" | "not_captive" | "unlocked_portal" | "locked_portal"]>
}
namespace clipboard {
function setImageData(imageData: ArrayBuffer, imageType: "png" | "jpeg"): Promise<void>
}
namespace commands {
type Command = {
name?: string
description?: string
shortcut?: string
}
function getAll(): Promise<Command[]>
function reset(name: string): Promise<void>
function update(details: { name: string, description?: string, shortcut?: string }): Promise<void>
const onCommand: events.Event<[name: string]>
}
namespace contentScripts {
type RegisteredContentScript = {
destroy(): void
}
function register(contentScriptOptions: {
allFrames?: boolean
css?: { file?: string, code?: string }[]
excludeGlobs?: string[]
excludeMatches?: string[]
includeGlobs?: string[]
js?: { file?: string, code?: string }[]
matchAboutBlank?: boolean
matches: string[]
runAt?: "document_start" | "document_end" | "document_idle"
}): Promise<RegisteredContentScript>
}
namespace contextualIdentities {
type ContextualIdentity = {
cookieStoreId: string
color: "blue" | "turquoise" | "green" | "yellow" | "orange" | "red" | "pink" | "purple" | "toolbar"
colorCode: string
icon: "fingerprint" | "briefcase" | "dollar" | "cart" | "circle" | "gift" | "vacation" | "food" | "fruit" | "pet" | "tree" | "chill" | "fence"
iconUrl: string
name: string
}
function create(details: { [key in "name" | "color" | "icon"]: ContextualIdentity[key] }): Promise<ContextualIdentity>
function get(cookieStoreId: string): Promise<ContextualIdentity>
function query(details: { name?: string }): Promise<ContextualIdentity[]>
function update(cookieStoreId: string, details: { [ P in "name" | "color" | "icon"]?: ContextualIdentity[P] }): Promise<ContextualIdentity>
function remove(cookieStoreId: string): Promise<ContextualIdentity>
const onCreated: events.Event<[changeInfo: { contextualIdentity: ContextualIdentity }]>
const onRemoved: events.Event<[changeInfo: { contextualIdentity: ContextualIdentity }]>
const onUpdated: events.Event<[changeInfo: { contextualIdentity: ContextualIdentity }]>
}
namespace cookies {
type Cookie = {
domain: string
expirationDate?: number
firstPartyDomain: string
hostOnly: boolean
httpOnly: boolean
name: string
path: string
sameSite: SameSiteStatus
secure: boolean
session: boolean
storeId: string
value: string
}
type CookieStore = {
id: string
incognito: boolean
tabIds: integer[]
}
type OnChangedCause = "evicted" | "expired" | "explicit" | "expired_overwrite" | "overwrite"
type SameSiteStatus = "no_restriction" | "lax" | "strict"
interface CookieParams extends Partial<Cookie> { url: string }
function get(details: { firstPartyDomain?: string, name: string, storeId?: string, url: string }): Promise<Cookie | null>
function getAll(details: { [key in "domain" | "firstPartyDomain" | "name" | "path" | "secure" | "session" | "storeId" | "url"]: CookieParams[key] }): Promise<Cookie[]>
function set(details: { [key in "domain" | "expirationDate" | "firstPartyDomain" | "httpOnly" | "name" | "path" | "sameSite" | "secure" | "storeId" | "url" | "value"]: CookieParams[key] }): Promise<Cookie>
function remove(details: { firstPartyDomain?: string, name: string, storeId?: string, url: string }): Promise<Cookie | null>
function getAllCookieStores(): Promise<CookieStore[]>
const onChanged: events.Event<[changeInfo: { removed: boolean, cookie: Cookie, cause: OnChangedCause }]>
}
namespace devtools {
namespace inspectedWindow {
const tabId: integer
function eval(expression: string, options?: {
frameURL?: string
useContentScriptContext?: boolean
contextSecurityOrigin?: string
}): Promise<[result: any, errorCause: { isException: true, value: string } | { isError: true, code: string }]>
function reload(reloadOptions?: {
ignoreCache?: boolean
userAgent?: string
injectedScript?: string
}): Promise<void>
}
namespace network {
interface HARData {
log: HARLog
}
interface HARObject {
comment?: string
[key: string]: any // `key: _${string}`
}
interface HARLog extends HARObject {
version: string
creator: { name: string, version: string } & HARObject
browser: { name: string, version: string } & HARObject
pages: HARPage[]
entries: HAREntry[]
}
interface HARPage extends HARObject {
startedDateTime: string
id: string
title: string
pageTimings: { onContentLoad?: number, onLoad?: number } & HARObject
}
interface HAREntry extends HARObject {
pageref?: string
startedDateTime: string
time: number
request: HARRequest
response: HARResponse
cache: { beforeRequest?: HARCache | null, afterRequest?: HARCache | null } & HARObject
timings: { blocked?: number, dns?: number, connect?: number, send: number, wait: number, receive: number, ssl?: number } & HARObject
serverIPAddress?: string
connection?: string
}
interface HARRequest extends HARObject {
method: string
url: string
httpVersion: string
cookies: HARCookie[]
headers: HARHeader[]
queryString: HARQueryParam[]
postData?: HARPostData
headersSize: number
bodySize: number
}
interface HARResponse extends HARObject {
status: number
statusText: string
httpVersion: string
cookies: HARCookie[]
headers: HARHeader[]
content: HARContent
redirectURL: string
headersSize: number
bodySize: number
}
interface HARCookie extends HARObject {
name: string
value: string
path?: string
domain?: string
expires?: string
httpOnly?: boolean
secure?: boolean
}
interface HARHeader extends HARObject {
name: string
value: string
}
interface HARQueryParam extends HARObject {
name: string
value: string
}
interface HARPostData extends HARObject {
mimeType: string
params: HARPostDataParam[]
text: string
}
interface HARPostDataParam extends HARObject {
name: string
value?: string
fileName?: string
contentType?: string
}
interface HARContent extends HARObject {
size: number
compression?: number
mimeType: string
text?: string
encoding?: string
}
interface HARCache extends HARObject {
expires?: string
lastAccess: string
eTag: string
hitCount: number
}
function getHAR(): Promise<HARData>
const onNavigated: events.Event<[url: string]>
const onRequestFinished: events.Event<[request: HAREntry]>
}
namespace panels {
type Button = {
update(iconPath: string, tooltipText: string, disabled: boolean): Promise<void>
onClicked: events.Event
}
type ElementsPanel = {
createSidebarPane(title: string): Promise<ExtensionSidebarPane>
onSelectionChanged: events.Event
}
type ExtensionPanel = {
onHidden: events.Event
// onSearch: events.Event<(action: string, queryString: string) => void>
onShown: events.Event
// createStatusBarButton(iconPath: string, tooltipText: string, disabled: boolean): Promise<Button>
}
type ExtensionSidebarPane = {
setExpression(expression: string, rootTitle?: string): Promise<void>
// setHeight(height: string): Promise<void>
setObject(jsonObject: string | any[] | Object, rootTitle?: string): Promise<void>
setPage(extensionPageURL: string): Promise<void>
}
type SourcesPanel = {
createSidebarPane(title: string): Promise<ExtensionSidebarPane>
onSelectionChanged: events.Event
}
const elements: ElementsPanel
// const sources: SourcesPanel
const themeName: "light" | "dark" | "firebug" // chrome: "default" | "dark"
function create(title: string, iconPath: string, pagePath: string): Promise<ExtensionPanel>
// function openResource(url: string, lineNumber: integer): Promise<void>
const onThemeChanged: events.Event<[themeName: "light" | "dark" | "firebug"]>
}
}
namespace dns {
type DNSRecord = {
addresses: string[]
canonicalName?: string
isTRR: boolean
}
function resolve(
hostname: string,
flags?: ("allow_name_collisions" | "bypass_cache" | "canonical_name" | "disable_ipv4" | "disable_ipv6" | "disable_trr" | "offline" | "priority_low" | "priority_medium" | "speculate")[]
): Promise<DNSRecord>
}
namespace downloads {
type FilenameConflictAction = "uniquify" | "overwrite" | "prompt"
type InterruptReason =
// File-related errors:
"FILE_FAILED" | "FILE_ACCESS_DENIED" | "FILE_NO_SPACE" | "FILE_NAME_TOO_LONG" | "FILE_TOO_LARGE" | "FILE_VIRUS_INFECTED" | "FILE_TRANSIENT_ERROR" | "FILE_BLOCKED" | "FILE_SECURITY_CHECK_FAILED" | "FILE_TOO_SHORT"
// Network-related errors:
| "NETWORK_FAILED" | "NETWORK_TIMEOUT" | "NETWORK_DISCONNECTED" | "NETWORK_SERVER_DOWN" | "NETWORK_INVALID_REQUEST"
// Server-related errors:
| "SERVER_FAILED" | "SERVER_NO_RANGE" | "SERVER_BAD_CONTENT" | "SERVER_UNAUTHORIZED" | "SERVER_CERT_PROBLEM" | "SERVER_FORBIDDEN"
// User-related errors:
| "USER_CANCELED" | "USER_SHUTDOWN"
// Miscellaneous:
| "CRASH"
type DangerType = "file" | "url" | "content" | "uncommon" | "host" | "unwanted" | "safe" | "accepted"
type State = "in_progress" | "interrupted" | "complete"
type DownloadItem = {
byExtensionId?: string
byExtensionName?: string
bytesReceived: number
canResume: boolean
danger: DangerType
endTime?: string
error?: InterruptReason
estimatedEndTime?: string
exists: boolean
filename: string
fileSize: number
id: integer
incognito: boolean
mime: string
paused: boolean
referrer: string
startTime: string
state: State
totalBytes: number
url: string
}
interface Delta<T> {
current?: T
previous?: T
}
type DownloadTime = Date | string | number
type DownloadQuery = {
query?: (Exclude<keyof DownloadItem | `-${keyof DownloadItem}`, "filename" | "url" | "-filename" | "-url">)[]
startedBefore?: DownloadTime
startedAfter?: DownloadTime
endedBefore?: DownloadTime
endedAfter?: DownloadTime
totalBytesGreater?: number
totalBytesLess?: number
filenameRegex?: string
urlRegex?: string
limit?: integer
orderBy?: (keyof DownloadItem | `-${keyof DownloadItem}`)[]
} & {
[key in "id" | "url" | "filename" | "danger" | "mime" | "startTime" | "endTime" | "bytesReceived" | "totalBytes" | "fileSize" | "exists"]?: DownloadItem[key]
}
function download(option: {
allowHttpErrors?: boolean
body?: string
conflictAction?: FilenameConflictAction
filename?: string
headers?: ({ name: string, value: string } | { name: string, binaryValue: ArrayBuffer })[]
incognito?: boolean
method?: "GET" | "POST"
saveAs?: boolean
url: string
}): Promise<DownloadItem["id"] | InterruptReason>
function search(query: DownloadQuery): Promise<DownloadItem[]>
function pause(downloadId: DownloadItem["id"]): Promise<void>
function resume(downloadId: DownloadItem["id"]): Promise<void>
function cancel(downloadId: DownloadItem["id"]): Promise<void>
function getFileIcon(downloadId: DownloadItem["id"], options?: { size?: integer }): Promise<string>
function open(downloadId: DownloadItem["id"]): Promise<void>
function show(downloadId: DownloadItem["id"]): Promise<boolean>
function showDefaultFolder(): Promise<void>
function erase(query: DownloadQuery): Promise<DownloadItem["id"][]>
function removeFile(downloadId: DownloadItem["id"]): Promise<void>
function acceptDanger(downloadId: DownloadItem["id"]): Promise<void>
// function setShelfEnabled(enabled: boolean): Promise<void>
const onCreated: events.Event<[downloadItem: DownloadItem]>
const onErased: events.Event<[downloadId: DownloadItem["id"]]>
const onChanged: events.Event<[downloadDelta: { id: DownloadItem["id"] } & {
[key in "url" | "filename" | "danger" | "mime" | "startTime" | "endTime" | "state" | "canResume" | "paused" | "error" | "totalBytes" | "fileSize" | "exists"]?: Delta<DownloadItem[key]>
}]>
}
namespace events {
type Event<T extends any[] = [], U = void, V extends any[] = []> = {
addListener(callback: (...args: T) => U, ...extraArgs: V): void
// addRules(eventName: string, webViewInstanceId: number, rules: Rule[], callback: (rules: Rule[]) => void): void
// getRules(eventName: string, webViewInstanceId: number, callback: (rules: Rule[]) => void): void
// getRules(eventName: string, webViewInstanceId: number, ruleIdentifiers: string[], callback: (rules: Rule[]) => void): void
hasListener(listener: (...args: T) => U): boolean
// hasListeners(): boolean
removeListener(listener: (...args: T) => U): void
// removeRules(eventName: string, webViewInstanceId: number, ruleIdentifiers: string[], callback: (rules: Rule[]) => void): void
}
type Rule = {
id?: string
tags?: string[]
conditions: any[]
actions: any[]
priority?: number
}
type UrlFilter = {
hostContains?: string
hostEquals?: string
hostPrefix?: string
hostSuffix?: string
pathContains?: string
pathEquals?: string
pathPrefix?: string
pathSuffix?: string
queryContains?: string
queryEquals?: string
queryPrefix?: string
querySuffix?: string
urlContains?: string
urlEquals?: string
urlMatches?: string
originAndPathMatches?: string
urlPrefix?: string
urlSuffix?: string
schemes?: string[]
ports?: (integer | [from: integer, to: integer])[]
}
}
namespace extension {
type ViewType = "tab" | "popup" | "sidebar"
/** @alias browser.runtime.lastError */
const lastError: Error | null
const inIncognitoContext: boolean
/** @alias browser.runtime.getBackgroundPage */
function getBackgroundPage(): Window
function getViews(fetchProperties?: {
type?: ViewType
windowId?: integer
}): Window[]
function isAllowedIncognitoAccess(): Promise<boolean>
function isAllowedFileSchemeAccess(): Promise<boolean>
function setUpdateUrlData(data: string): void
}
namespace extensionTypes {
type ImageDetails = {
format?: ImageFormat
quality?: number
rect?: { [key in "x" | "y" | "width" | "height"]: integer }
scale?: number
}
type ImageFormat = "jpeg" | "png"
type InjectDetails = {
allFrames?: boolean
code?: string
cssOrigin?: CSSOrigin // unavailable in executeScript
file?: string
frameId?: integer
matchAboutBlank?: boolean
runAt?: RunAt // unavailable in removeCSS
}
type RunAt = "document_start" | "document_end" | "document_idle"
type CSSOrigin = "user" | "author"
}
namespace find {
interface RangeData {
framePos: integer
startTextNodePos: integer
endTextNodePos: integer
startOffset: integer
endOffset: integer
}
interface RectData {
rectsAndTexts: {
rectList: { [key in "top" | "left" | "bottom" | "right"]: integer }[]
textList: string[]
}
text: string
}
function find(queryphrase: string, options?: {
tabId?: integer
caseSensitive?: boolean
entireWord?: boolean
includeRangeData?: boolean
includeRectData?: boolean
}): Promise<{
count: integer
rangeData?: RangeData[]
rectData?: RectData[]
}>
function highlightResults(options?: {
tabId?: integer
rangeIndex?: integer
noScroll?: boolean
}): Promise<void>
function removeHighlighting(): Promise<void>
}
namespace history {
type TransitionType = "link" | "typed" | "auto_bookmark" | "auto_subframe" | "manual_subframe" | "generated" | "auto_toplevel" | "form_submit" | "reload" | "keyword" | "keyword_generated"
type HistoryItem = {
id: string
url?: string
title?: string
lastVisitTime?: number
visitCount?: integer
typedCount?: integer
}
type VisitItem = {
id: HistoryItem["id"]
visitId: string
visitTime?: number
referringVisitId: string
transition: TransitionType
}
function search(query: {
text: string
startTime?: number | string | Date
endTime?: number | string | Date
maxResults?: integer
}): Promise<HistoryItem[]>
function getVisits(details: { url: string }): Promise<VisitItem[]>
function addUrl(details: {
url: string
title?: string
transition?: TransitionType
visitTime?: number | string | Date
}): Promise<void>
function deleteUrl(details: { url: string }): Promise<void>
function deleteRange(details: {
startTime: number | string | Date
endTime: number | string | Date
}): Promise<void>
function deleteAll(): Promise<void>
const onTitleChanged: events.Event<[url: string, title: string]>
const onVisited: events.Event<[result: HistoryItem]>
const onVisitRemoved: events.Event<[removed: { allHistory: boolean, urls: string[] }]>
}
namespace i18n {
type LanguageCode = string
function getAcceptLanguages(): Promise<LanguageCode[]>
function getMessage(messageName: string): string
function getMessage(messageName: string, substitutions: string | string[]): string
function getUILanguage(): LanguageCode
function detectLanguage(text: string): Promise<{ isReliable: boolean, languages: [language: LanguageCode, percentage: number ]}>
}
namespace identity {
function getRedirectURL(): string
function launchWebAuthFlow(details: {
url: string
redirect_uri?: string
interactive: boolean
}): Promise<string>
}
namespace idle {
type IdleState = "active" | "idle" | "locked"
function queryState(detectionIntervalInSeconds: number): Promise<IdleState>
function setDetectionInterval(intervalInSeconds: number): void
const onStateChanged: events.Event<[newState: IdleState]>
}
namespace management {
type ExtensionInfo = {
description: string
// disabledReason: "unknown" | "permissions_increase"
enabled: boolean
homepageUrl: string
hostPermissions: string[]
icons: { size: number, url: string }[]
id: string
installType: "admin" | "development" | "normal" | "sideload" | "other"
mayDisable: boolean
name: string
// offlineEnabled: boolean
optionsUrl: string
permissions: string[]
shortName: string
type: "extension" | "hosted_app" | "packaged_app" | "legacy_packaged_app" | "theme"
updateUrl: string
version: string
// versionName: string
}
function getAll(): Promise<ExtensionInfo[]>
function get(id: string): Promise<ExtensionInfo>
function getSelf(): Promise<ExtensionInfo>
function install(options: { url: string }): Promise<{ id: string }>
// function uninstall(id: string, options?: { showConfirmDialog?: boolean }): Promise<void>
function uninstallSelf(options?: {
showConfirmDialog?: boolean
// dialogMessage: string
}): Promise<void>
// function getPermissionWarningsById(id: string): Promise<string[]>
// function getPermissionWarningsByManifest(manifestString: string): Promise<string[]>
function setEnabled(id: string, enabled: boolean): Promise<void>
const onInstalled: events.Event<[info: ExtensionInfo]>
const onUninstalled: events.Event<[info: ExtensionInfo]>
const onEnabled: events.Event<[info: ExtensionInfo]>
const onDisabled: events.Event<[info: ExtensionInfo]>
}
namespace menus {
type ContextType = "all" | "audio" | "bookmark" | "browser_action" | "editable" | "frame" | "image" | "link" | "page" | "page_action" | "password" | "selection" | "tab" | "tools_menu" | "video"
type ItemType = "normal" | "checkbox" | "radio" | "separator"
type OnClickData = {
bookmarkId?: string
button?: integer
checked?: boolean
editable: boolean
frameId?: integer
frameUrl?: string
linkText?: string
mediaType?: "image" | "video" | "audio"
menuItemId: integer | string
modifiers: ("Alt" | "Command" | "Ctrl" | "MacCtrl" | "Shift")[]
pageUrl?: string
parentMenuItemId?: integer | string
selectionText?: string
srcUrl?: string
targetElementId?: integer
viewType?: extension.ViewType
wasChecked?: boolean
}
const ACTION_MENU_TOP_LEVEL_LIMIT: 6
function create(createProperties: {
checked?: boolean
command?: "_execute_browser_action" | "_execute_page_action" | "_execute_sidebar_action"
contexts?: ContextType[]
documentUrlPatterns?: string[]
enabled?: boolean
icons?: { [key: string]: string }
id?: string
onclick?: (info: OnClickData, tab: tabs.Tab) => void
parentId?: integer | string
targetUrlPatterns?: string[]
title?: string
type?: ItemType
viewTypes?: extension.ViewType
visible?: boolean
}, callback: () => void): integer | string
function getTargetElement(targetElementId: OnClickData["targetElementId"]): Element
function overrideContext(contextOptions: { showDefaults: boolean } | { context: "bookmark", bookmarkId: string } | { context: "tab", tabId: integer }): Promise<void>
function refresh(): Promise<void>
function remove(menuItemId: integer | string): Promise<void>
function removeAll(): Promise<void>
function update(id: integer | string, updateProperties: {
checked?: boolean
command?: "_execute_browser_action" | "_execute_page_action" | "_execute_sidebar_action"
contexts?: ContextType[]
documentUrlPatterns?: string[]
enabled?: boolean
icons?: { [key: string]: string }
id?: string
onclick?: (info: OnClickData, tab: tabs.Tab) => void
parentId?: integer | string
targetUrlPatterns?: string[]
title?: string
type?: ItemType
viewTypes?: extension.ViewType
visible?: boolean
}): Promise<void>
const onClicked: events.Event<[info: OnClickData, tab: tabs.Tab]>
const onHidden: events.Event
const onShown: events.Event<[info: { contexts: ContextType[], menuIds: (integer | string)[] }
& { [key in "editable" | "frameId"]: OnClickData[key] }
& { [key in "bookmarkId" | "button" | "checked" | "frameUrl" | "linkText" | "mediaType" | "pageUrl" | "parentMenuItemId" | "selectionText" | "srcUrl" | "targetElementId" | "viewType" | "wasChecked"]?: OnClickData[key]
}, tab: tabs.Tab]>
}
namespace notifications {
type NotificationOptions = {
type: TemplateType
message: string
title: string
iconUrl?: string
contextMessage?: string
priority?: 0 | 1 | 2
eventTime?: number
// buttons?: { title: string, iconUrl?: string }[]
// imageUrl: string
// items: { title: string, message: string }[]
// progress: number
}
type TemplateType = "basic"// | "image" | "list" | "progress"
function clear(id: string): Promise<boolean>
function create(id: string, options: NotificationOptions): Promise<string>
function create(options: NotificationOptions): Promise<string>
function getAll(): Promise<{ [key: string]: NotificationOptions }>
// function update(id: string, options: NotificationOptions): Promise<boolean>
const onButtonClicked: events.Event<[notificationId: string, buttonIndex: integer]>
const onClicked: events.Event<[notificationId: string]>
const onClosed: events.Event<[notificationId: string]> // byUser: boolean
const onShown: events.Event<[notificationId: string]>
}
namespace omnibox {
type OnInputEnteredDisposition = "currentTab" | "newForegroundTab" | "newBackgroundTab"
type SuggestResult = {
content: string
description: string
}
function setDefaultSuggestion(suggestion: { description: string }): void
const onInputStarted: events.Event
const onInputChanged: events.Event<[text: string, suggest: (suggestions: SuggestResult[]) => void]>
const onInputEntered: events.Event<[text: SuggestResult["content"], disposition: OnInputEnteredDisposition]>
const onInputCancelled: events.Event
}
namespace pageAction {
type ImageDataType = ImageData
function show(id: integer): Promise<void>
function hide(id: integer): Promise<void>
function isShown(details: { tabId: integer }): Promise<boolean>
function setTitle(details: { tabId: integer, title: string | null }): Promise<void>
function getTitle(details: { tabId: integer }): Promise<string>
function setIcon(details: {
imageData?: ImageDataType | { [key: number]: ImageData }
path?: string | { [key: number]: string }
tabId: integer
}): Promise<void>
function setPopup(details: { tabId: integer, popup: string | null }): Promise<void>
function getPopup(details: { tabId: integer }): Promise<string>
function openPopup(): Promise<void>
const onClicked: events.Event<[tab: tabs.Tab, onClickData: { modifiers: ("Shift" | "Alt" | "Command" | "Ctrl" | "MacCtrl")[], button: integer }]>
}
namespace permissions {
type Permissions = {
origins?: string[]
permissions?: string[]
}
function contains(permissions: Permissions): Promise<boolean>
function getAll(): Promise<Permissions>
function remove(permissionts: Permissions): Promise<boolean>
function request(permissions: Permissions): Promise<boolean>
const onAdded: events.Event<[permissions: Permissions]>
const onRemoved: events.Event<[permissions: Permissions]>
}
namespace privacy {
interface _NetworkSettingsTypes {
networkPredictionEnabled: boolean
peerConnectionEnabled: boolean
webRTCIPHandlingPolicy: "default" | "default_public_and_private_interfaces" | "default_public_interface_only" | "disable_non_proxied_udp" |"proxy_only"
httpsOnlyMode: "always" | "never" | "private_browsing"
}
interface _ServicesSettingsTypes {
passwordSavingEnabled: boolean
}
interface _WebsitesSettingsTypes {
cookieConfig: {
behavior: "allow_all" | "reject_all" | "reject_third_party" | "allow_visited" | "reject_trackers" | "reject_trackers_and_partition_foreign"
nonPersistentCookies: boolean
}
firstPartyIsolate: boolean
hyperlinkAuditingEnabled: boolean
protectedContentEnabled: boolean
referrersEnabled: boolean
resistFingerprinting: boolean
thirdPartyCookiesAllowed: boolean
trackingProtectionMode: boolean
}
const network: { [key in keyof _NetworkSettingsTypes]: types.BrowserSetting<_NetworkSettingsTypes[key]> }
const services: { [key in keyof _ServicesSettingsTypes]: types.BrowserSetting<_ServicesSettingsTypes[key]> }
const websites: { [key in keyof _WebsitesSettingsTypes]: types.BrowserSetting<_WebsitesSettingsTypes[key]> }
}
namespace proxy {
type ProxyInfo = {
type: "direct" | "http" | "https" | "socks" | "socks4"
host?: string
port?: string
username?: string
password?: string
proxyDNS?: boolean
failoverTimeout: number
proxyAuthorizationHeader: string
connectionIsolationKey?: string
}
type RequestDetails = {
cookieStoreId: string
documentUrl: string
frameId: integer
fromCache: boolean
incognito: boolean
method: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH"
originUrl: string
parentFrameId: integer
requestId: string
requestHeaders?: webRequest.HttpHeaders
tabId: integer
thirdParty: boolean
timeStamp: number
type: webRequest.ResourceType
url: string
}
interface _SettingsTypes {
autoConfigUrl: string
autoLogin: boolean
http: string
httpProxyAll: boolean
passthrough: string
proxyDNS: boolean
proxyType: "none" | "autoDetect" | "system" | "manual" | "autoConfig"
socks: string
socksVersion: 4 | 5
ssl: string
}
const settings: { [key in keyof _SettingsTypes]?: types.BrowserSetting<_SettingsTypes[key]> }
const onError: events.Event<[newState: Error]>
const onRequest: events.Event<[requestInfo: RequestDetails], ProxyInfo | ProxyInfo[] | Promise<ProxyInfo> | Promise<ProxyInfo[]>, [filter: webRequest.RequestFilter, extraInfoSpec?: string[]]>
}
namespace runtime {
type Port<T = MessageSender> = {
disconnect(): Promise<void>
postMessage(message: {}): Promise<void>
error: Error
name: string
sender?: T
onDisconnect: events.Event<[port: Port]>
onMessage: events.Event<[message: object]>
}
type MessageSender = {
tab?: tabs.Tab
frameId?: integer
id?: string
url?: string
tlsChannelId?: string
}
type PlatformOs = "mac" | "win" | "android" | "cros" | "linux" | "openbsd"
type PlatformArch = "arm" | "x86-32" | "x86-64"
type PlatformNaclArch = "arm" | "x86-32" | "x86-64"
type PlatformInfo = {
os: PlatformOs
arch: PlatformArch
nacl_arch: PlatformNaclArch
}
type RequestUpdateCheckStatus = "throttled" | "no_update" | "update_available"
type OnInstalledReason = "install" | "update" | "browser_update" | "shared_module_update"
type OnRestartRequiredReason = "app_update" | "os_update" | "periodic"
const lastError: Error | null
const id: string
function getBackgroundPage(): Promise<Window>
function openOptionsPage(): Promise<void>
function getManifest(): { [key: string]: any }
function getURL(path: string): string
function setUninstallURL(url: string): Promise<void>
function reload(): void
function requestUpdateCheck(): Promise<[status: RequestUpdateCheckStatus, details?: { version: string }]>
function connect(extensionId?: string, connectInfo?: { name?: string, includeTlsChannelId?: boolean }): Port
function connectNative(application: string): Port
function sendMessage(extensionId: string, message: any, options?: { includeTlsChannelId?: boolean }): Promise<any>
function sendMessage(message: any, options?: { includeTlsChannelId?: boolean }): Promise<any>
function sendNativeMessage(application: string, message: object): Promise<any>
function getPlatformInfo(): Promise<PlatformInfo>
function getBrowserInfo(): Promise<{ [key in "name" | "vendor" | "version" | "buildID"]: string }>
// function getPackageDirectoryEntry(): Promise<DirectoryEntry>
const onStartup: events.Event
const onInstalled: events.Event<[details: { id?: string, previousVersion?: string, reason: OnInstalledReason, temporary: boolean }]>
// const onSuspend: events.Event
// const onSuspendCanceled: events.Event
const onUpdateAvailable: events.Event<[details: { version: string }]>
const onConnect: events.Event<[port: Required<Port<Required<MessageSender>>>]>
const onConnectExternal: events.Event<[port: Required<Port<Required<MessageSender>>>]>
const onMessage: events.Event<[message: object, sender: MessageSender, sendResponse: (message: object) => any], void | boolean | Promise<any>>
const onMessageExternal: events.Event<[message: object, sender: MessageSender, sendResponse: (message: object) => any], void | boolean | Promise<any>>
// const onRestartRequired: events.Event<[reason: OnRestartRequiredReason]>
}
namespace search {
function get(): Promise<{
name: string
isDefault: boolean
alias?: string
favIconUrl?: string
}[]>
function search(searchProperties: {
query: string
engine?: string
tabId?: integer
}): void
}
namespace sessions {
type Filter = {
maxResults: integer
}
type Session = {
lastModified: number
tab: tabs.Tab // "tabs" permission or host permissions required
window?: windows.Window
}
const MAX_SESSION_RESULTS = 25
function forgetClosedTab(windowId: integer, sessionId: string): Promise<void>
function forgetClosedWindow(sessionId: string): Promise<void>
function getRecentlyClosed(filter?: Filter): Promise<Session[]>
function restore(sessionId: string): Promise<Session>
function setTabValue(tabId: integer, key: string, value: string | object | null): Promise<void>
function getWindowValue(windowId: integer, key: string): Promise<string | object | null | undefined>
function removeWindowValue(windowId: integer, key: string): Promise<void>
const onChanged: events.Event
}
namespace sidebarAction {
type ImageDataType = ImageData
function close(): Promise<void>
function getPanel(details: { tabId?: integer, windowId?: integer }): Promise<string>
function getTitle(details: { tabId?: integer, windowId?: integer }): Promise<string>
function isOpen(details: { windowId?: integer }): Promise<boolean>
function open(): Promise<void>
function setIcon(details: {
imageData?: ImageDataType | { [key: number]: string }[]
path?: string | { [key: number]: string }[]
tabId?: integer
windowId?: integer
}): Promise<void>
function setPanel(details: { panel: string | null, tabId?: integer, windowId?: integer }): Promise<void>
function setTitle(details: { title: string | null, tabId?: integer, windowId?: integer }): Promise<void>
function toggle(): Promise<void>
}
namespace storage {
type StorageArea = {
get(keys?: string | string[] | null): Promise<{ [key: string]: any }>
get(defaultValues: { [key: string]: any }): Promise<{ [key: string]: any }>
getBytesInUse(keys?: string | string[] | null): Promise<integer>
set(keys: object): Promise<void>
remove(keys?: string | string[] | null): Promise<{ [key: string]: any }>
clear(): Promise<void>
}
type StorageChange = {
oldValue?: any
newValue?: any
}
const sync: StorageArea
const local: StorageArea
const managed: Pick<StorageArea, "get">