-
Notifications
You must be signed in to change notification settings - Fork 32
/
chrome-extension-async.d.ts
7709 lines (7152 loc) · 402 KB
/
chrome-extension-async.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
// Extended from type definitions for Chrome extension development
// Project: http://developer.chrome.com/extensions/
// Adapted from originals by: Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>, couven92 <https://github.com/couven92>, RReverser <https://github.com/rreverser>, sreimer15 <https://github.com/sreimer15>
////////////////////
// Global object
////////////////////
interface Window {
chrome: typeof chrome;
}
////////////////////
// Accessibility Features
////////////////////
/**
* Use the chrome.accessibilityFeatures API to manage Chrome's accessibility features. This API relies on the ChromeSetting prototype of the type API for getting and setting individual accessibility features. In order to get feature states the extension must request accessibilityFeatures.read permission. For modifying feature state, the extension needs accessibilityFeatures.modify permission. Note that accessibilityFeatures.modify does not imply accessibilityFeatures.read permission.
* Availability: Since Chrome 37.
* Permissions: "accessibilityFeatures.read"
* Important: This API works only on Chrome OS.
*/
declare namespace chrome.accessibilityFeatures {
interface AccessibilityFeaturesGetArg {
/** Optional. Whether to return the value that applies to the incognito session (default false). */
incognito?: boolean;
}
interface AccessibilityFeaturesCallbackArg {
/** The value of the setting. */
value: any;
/**
* One of
* • not_controllable: cannot be controlled by any extension
* • controlled_by_other_extensions: controlled by extensions with higher precedence
* • controllable_by_this_extension: can be controlled by this extension
* • controlled_by_this_extension: controlled by this extension
*/
levelOfControl: string;
/** Optional. Whether the effective value is specific to the incognito session. This property will only be present if the incognito property in the details parameter of get() was true. */
incognitoSpecific?: boolean;
}
interface AccessibilityFeaturesSetArg {
/**
* The value of the setting.
* Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type.
*/
value: any;
/**
* Optional.
* The scope of the ChromeSetting. One of
* • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere),
* • regular_only: setting for the regular profile only (not inherited by the incognito profile),
* • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences),
* • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences).
*/
scope?: string;
}
interface AccessibilityFeaturesClearArg {
/**
* Optional.
* The scope of the ChromeSetting. One of
* • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere),
* • regular_only: setting for the regular profile only (not inherited by the incognito profile),
* • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences),
* • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences).
*/
scope?: string;
}
interface AccessibilityFeaturesSetting {
/**
* Gets the value of a setting.
* @param details Which setting to consider.
* @param callback The callback parameter should be a function that looks like this:
* function(object details) {...};
* @returns Promise that resolves with the features
*/
get(details: AccessibilityFeaturesGetArg, callback?: (details: AccessibilityFeaturesCallbackArg) => void): Promise<AccessibilityFeaturesCallbackArg>;
/**
* Sets the value of a setting.
* @param details Which setting to change.
* @param callback Called at the completion of the set operation.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
set(details: AccessibilityFeaturesSetArg, callback?: () => void): Promise<void>;
/**
* Clears the setting, restoring any default value.
* @param details Which setting to clear.
* @param callback Called at the completion of the clear operation.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
clear(details: AccessibilityFeaturesClearArg, callback?: () => void): Promise<void>;
}
var spokenFeedback: AccessibilityFeaturesSetting;
var largeCursor: AccessibilityFeaturesSetting;
var stickyKeys: AccessibilityFeaturesSetting;
var highContrast: AccessibilityFeaturesSetting;
var screenMagnifier: AccessibilityFeaturesSetting;
var autoclick: AccessibilityFeaturesSetting;
var virtualKeyboard: AccessibilityFeaturesSetting;
var animationPolicy: AccessibilityFeaturesSetting;
}
////////////////////
// Alarms
////////////////////
/**
* Use the chrome.alarms API to schedule code to run periodically or at a specified time in the future.
* Availability: Since Chrome 22.
* Permissions: "alarms"
*/
declare namespace chrome.alarms {
interface AlarmCreateInfo {
/** Optional. Length of time in minutes after which the onAlarm event should fire. */
delayInMinutes?: number;
/** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */
periodInMinutes?: number;
/** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */
when?: number;
}
interface Alarm {
/** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */
periodInMinutes?: number;
/** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */
scheduledTime: number;
/** Name of this alarm. */
name: string;
}
interface AlarmEvent extends chrome.events.Event<(alarm: Alarm) => void> { }
/**
* Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
* In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
* To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
* @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
*/
export function create(alarmInfo: AlarmCreateInfo): void;
/**
* Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
* In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
* To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
* @param name Optional name to identify this alarm. Defaults to the empty string.
* @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
*/
export function create(name: string, alarmInfo: AlarmCreateInfo): void;
/**
* Gets an array of all the alarms.
* @param callback The callback parameter should be a function that looks like this:
* function(array of Alarm alarms) {...};
*/
export function getAll(callback?: (alarms: Alarm[]) => void): Promise<Alarm[]>;
/**
* Clears all alarms.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(boolean wasCleared) {...};
*/
export function clearAll(callback?: (wasCleared: boolean) => void): Promise<boolean>;
/**
* Clears the alarm with the given name.
* @param name The name of the alarm to clear. Defaults to the empty string.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(boolean wasCleared) {...};
*/
export function clear(name?: string, callback?: (wasCleared: boolean) => void): Promise<boolean>;
/**
* Clears the alarm without a name.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(boolean wasCleared) {...};
*/
export function clear(callback?: (wasCleared: boolean) => void): Promise<boolean>;
/**
* Retrieves details about the specified alarm.
* @param callback The callback parameter should be a function that looks like this:
* function( Alarm alarm) {...};
*/
export function get(callback?: (alarm?: Alarm) => void): Promise<Alarm>;
/**
* Retrieves details about the specified alarm.
* @param name The name of the alarm to get. Defaults to the empty string.
* @param callback The callback parameter should be a function that looks like this:
* function( Alarm alarm) {...};
*/
export function get(name: string, callback?: (alarm: Alarm) => void): Promise<Alarm>;
/** Fired when an alarm has elapsed. Useful for event pages. */
var onAlarm: AlarmEvent;
}
/**
* Use the chrome.browser API to interact with the Chrome browser associated with
* the current application and Chrome profile.
*/
declare namespace chrome.browser {
interface Options {
/** The URL to navigate to when the new tab is initially opened. */
url: string;
}
/**
* Opens a new tab in a browser window associated with the current application
* and Chrome profile. If no browser window for the Chrome profile is opened,
* a new one is opened prior to creating the new tab.
* @param options Configures how the tab should be opened.
* @param callback Called when the tab was successfully
* created, or failed to be created. If failed, runtime.lastError will be set.
*/
export function openTab(options: Options, callback?: () => void): Promise<void>;
/**
* Opens a new tab in a browser window associated with the current application
* and Chrome profile. If no browser window for the Chrome profile is opened,
* a new one is opened prior to creating the new tab. Since Chrome 42 only.
* @param options Configures how the tab should be opened.
*/
export function openTab(options: Options): void;
}
////////////////////
// Bookmarks
////////////////////
/**
* Use the chrome.bookmarks API to create, organize, and otherwise manipulate bookmarks. Also see Override Pages, which you can use to create a custom Bookmark Manager page.
* Availability: Since Chrome 5.
* Permissions: "bookmarks"
*/
declare namespace chrome.bookmarks {
/** A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder. */
interface BookmarkTreeNode {
/** Optional. The 0-based position of this node within its parent folder. */
index?: number;
/** Optional. When this node was created, in milliseconds since the epoch (new Date(dateAdded)). */
dateAdded?: number;
/** The text displayed for the node. */
title: string;
/** Optional. The URL navigated to when a user clicks the bookmark. Omitted for folders. */
url?: string;
/** Optional. When the contents of this folder last changed, in milliseconds since the epoch. */
dateGroupModified?: number;
/** The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted. */
id: string;
/** Optional. The id of the parent folder. Omitted for the root node. */
parentId?: string;
/** Optional. An ordered list of children of this node. */
children?: BookmarkTreeNode[];
/**
* Optional.
* Since Chrome 37.
* Indicates the reason why this node is unmodifiable. The managed value indicates that this node was configured by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user and the extension (default).
*/
unmodifiable?: any;
}
interface BookmarkRemoveInfo {
index: number;
parentId: string;
}
interface BookmarkMoveInfo {
index: number;
oldIndex: number;
parentId: string;
oldParentId: string;
}
interface BookmarkChangeInfo {
url?: string;
title: string;
}
interface BookmarkReorderInfo {
childIds: string[];
}
interface BookmarkRemovedEvent extends chrome.events.Event<(id: string, removeInfo: BookmarkRemoveInfo) => void> { }
interface BookmarkImportEndedEvent extends chrome.events.Event<() => void> { }
interface BookmarkMovedEvent extends chrome.events.Event<(id: string, moveInfo: BookmarkMoveInfo) => void> { }
interface BookmarkImportBeganEvent extends chrome.events.Event<() => void> { }
interface BookmarkChangedEvent extends chrome.events.Event<(id: string, changeInfo: BookmarkChangeInfo) => void> { }
interface BookmarkCreatedEvent extends chrome.events.Event<(id: string, bookmark: BookmarkTreeNode) => void> { }
interface BookmarkChildrenReordered extends chrome.events.Event<(id: string, reorderInfo: BookmarkReorderInfo) => void> { }
interface BookmarkSearchQuery {
query?: string;
url?: string;
title?: string;
}
interface BookmarkCreateArg {
/** Optional. Defaults to the Other Bookmarks folder. */
parentId?: string;
index?: number;
title?: string;
url?: string;
}
interface BookmarkDestinationArg {
parentId?: string;
index?: number;
}
interface BookmarkChangesArg {
title?: string;
url?: string;
}
/** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */
var MAX_WRITE_OPERATIONS_PER_HOUR: number;
/** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */
var MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number;
/**
* Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties.
* @param query A string of words and quoted phrases that are matched against bookmark URLs and titles.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function search(query: string, callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties.
* @param query An object with one or more of the properties query, url, and title specified. Bookmarks matching all specified properties will be produced.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function search(query: BookmarkSearchQuery, callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Retrieves the entire Bookmarks hierarchy.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getTree(callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Retrieves the recently added bookmarks.
* @param numberOfItems The maximum number of items to return.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getRecent(numberOfItems: number, callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Retrieves the specified BookmarkTreeNode.
* @param id A single string-valued id
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function get(id: string, callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Retrieves the specified BookmarkTreeNode.
* @param idList An array of string-valued ids
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function get(idList: string[], callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( BookmarkTreeNode result) {...};
*/
export function create(bookmark: BookmarkCreateArg, callback?: (result: BookmarkTreeNode) => void): Promise<BookmarkTreeNode>;
/**
* Moves the specified BookmarkTreeNode to the provided location.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( BookmarkTreeNode result) {...};
*/
export function move(id: string, destination: BookmarkDestinationArg, callback?: (result: BookmarkTreeNode) => void): Promise<BookmarkTreeNode>;
/**
* Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged. Note: Currently, only 'title' and 'url' are supported.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( BookmarkTreeNode result) {...};
*/
export function update(id: string, changes: BookmarkChangesArg, callback?: (result: BookmarkTreeNode) => void): Promise<BookmarkTreeNode>;
/**
* Removes a bookmark or an empty bookmark folder.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function remove(id: string, callback?: Function): Promise<void>;
/**
* Retrieves the children of the specified BookmarkTreeNode id.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getChildren(id: string, callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Since Chrome 14.
* Retrieves part of the Bookmarks hierarchy, starting at the specified node.
* @param id The ID of the root of the subtree to retrieve.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getSubTree(id: string, callback?: (results: BookmarkTreeNode[]) => void): Promise<BookmarkTreeNode[]>;
/**
* Recursively removes a bookmark folder.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeTree(id: string, callback?: Function): Promise<void>;
/** Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents. */
var onRemoved: BookmarkRemovedEvent;
/** Fired when a bookmark import session is ended. */
var onImportEnded: BookmarkImportEndedEvent;
/** Fired when a bookmark import session is begun. Expensive observers should ignore onCreated updates until onImportEnded is fired. Observers should still handle other notifications immediately. */
var onImportBegan: BookmarkImportBeganEvent;
/** Fired when a bookmark or folder changes. Note: Currently, only title and url changes trigger this. */
var onChanged: BookmarkChangedEvent;
/** Fired when a bookmark or folder is moved to a different parent folder. */
var onMoved: BookmarkMovedEvent;
/** Fired when a bookmark or folder is created. */
var onCreated: BookmarkCreatedEvent;
/** Fired when the children of a folder have changed their order due to the order being sorted in the UI. This is not called as a result of a move(). */
var onChildrenReordered: BookmarkChildrenReordered;
}
////////////////////
// Browser Action
////////////////////
/**
* Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.
* Availability: Since Chrome 5.
* Manifest: "browser_action": {...}
*/
declare namespace chrome.browserAction {
interface BadgeBackgroundColorDetails {
/** An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is [255, 0, 0, 255]. Can also be a string with a CSS value, with opaque red being #FF0000 or #F00. */
color: any;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
}
interface BadgeTextDetails {
/** Any number of characters can be passed, but only about four can fit in the space. */
text: string;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
}
interface TitleDetails {
/** The string the browser action should display when moused over. */
title: string;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
}
interface TabDetails {
/** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */
tabId?: number;
}
interface TabIconDetails {
/** Optional. Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' */
path?: any;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
/** Optional. Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' */
imageData?: ImageData;
}
interface PopupDetails {
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
/** The html file to show in a popup. If set to the empty string (''), no popup is shown. */
popup: string;
}
interface BrowserClickedEvent extends chrome.events.Event<(tab: chrome.tabs.Tab) => void> { }
/**
* Since Chrome 22.
* Enables the browser action for a tab. By default, browser actions are enabled.
* @param tabId The id of the tab for which you want to modify the browser action.
*/
export function enable(tabId?: number): void;
/** Sets the background color for the badge. */
export function setBadgeBackgroundColor(details: BadgeBackgroundColorDetails): void;
/** Sets the badge text for the browser action. The badge is displayed on top of the icon. */
export function setBadgeText(details: BadgeTextDetails): void;
/** Sets the title of the browser action. This shows up in the tooltip. */
export function setTitle(details: TitleDetails): void;
/**
* Since Chrome 19.
* Gets the badge text of the browser action. If no tab is specified, the non-tab-specific badge text is returned.
* @param callback The callback parameter should be a function that looks like this:
* function(string result) {...};
*/
export function getBadgeText(details: TabDetails, callback?: (result: string) => void): Promise<string>;
/** Sets the html document to be opened as a popup when the user clicks on the browser action's icon. */
export function setPopup(details: PopupDetails): void;
/**
* Since Chrome 22.
* Disables the browser action for a tab.
* @param tabId The id of the tab for which you want to modify the browser action.
*/
export function disable(tabId?: number): void;
/**
* Since Chrome 19.
* Gets the title of the browser action.
* @param callback The callback parameter should be a function that looks like this:
* function(string result) {...};
*/
export function getTitle(details: TabDetails, callback?: (result: string) => void): Promise<string>;
/**
* Since Chrome 19.
* Gets the background color of the browser action.
* @param callback The callback parameter should be a function that looks like this:
* function( ColorArray result) {...};
*/
export function getBadgeBackgroundColor(details: TabDetails, callback?: (result: number[]) => void): Promise<number[]>;
/**
* Since Chrome 19.
* Gets the html document set as the popup for this browser action.
* @param callback The callback parameter should be a function that looks like this:
* function(string result) {...};
*/
export function getPopup(details: TabDetails, callback?: (result: string) => void): Promise<string>;
/**
* Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function setIcon(details: TabIconDetails, callback?: Function): Promise<void>;
/** Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. */
var onClicked: BrowserClickedEvent;
}
////////////////////
// Browsing Data
////////////////////
/**
* Use the chrome.browsingData API to remove browsing data from a user's local profile.
* Availability: Since Chrome 19.
* Permissions: "browsingData"
*/
declare namespace chrome.browsingData {
interface OriginTypes {
/** Optional. Websites that have been installed as hosted applications (be careful!). */
protectedWeb?: boolean;
/** Optional. Extensions and packaged applications a user has installed (be _really_ careful!). */
extension?: boolean;
/** Optional. Normal websites. */
unprotectedWeb?: boolean;
}
/** Options that determine exactly what data will be removed. */
interface RemovalOptions {
/**
* Optional.
* Since Chrome 21.
* An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that you really want to remove application data before adding 'protectedWeb' or 'extensions'.
*/
originTypes?: OriginTypes;
/** Optional. Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the getTime method of the JavaScript Date object). If absent, defaults to 0 (which would remove all browsing data). */
since?: number;
}
/**
* Since Chrome 27.
* A set of data types. Missing data types are interpreted as false.
*/
interface DataTypeSet {
/** Optional. Websites' WebSQL data. */
webSQL?: boolean;
/** Optional. Websites' IndexedDB data. */
indexedDB?: boolean;
/** Optional. The browser's cookies. */
cookies?: boolean;
/** Optional. Stored passwords. */
passwords?: boolean;
/** Optional. Server-bound certificates. */
serverBoundCertificates?: boolean;
/** Optional. The browser's download list. */
downloads?: boolean;
/** Optional. The browser's cache. Note: when removing data, this clears the entire cache: it is not limited to the range you specify. */
cache?: boolean;
/** Optional. Websites' appcaches. */
appcache?: boolean;
/** Optional. Websites' file systems. */
fileSystems?: boolean;
/** Optional. Plugins' data. */
pluginData?: boolean;
/** Optional. Websites' local storage data. */
localStorage?: boolean;
/** Optional. The browser's stored form data. */
formData?: boolean;
/** Optional. The browser's history. */
history?: boolean;
/**
* Optional.
* Since Chrome 39.
* Service Workers.
*/
serviceWorkers?: boolean;
}
interface SettingsCallback {
options: RemovalOptions;
/** All of the types will be present in the result, with values of true if they are both selected to be removed and permitted to be removed, otherwise false. */
dataToRemove: DataTypeSet;
/** All of the types will be present in the result, with values of true if they are permitted to be removed (e.g., by enterprise policy) and false if not. */
dataRemovalPermitted: DataTypeSet;
}
/**
* Since Chrome 26.
* Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here.
* @param callback The callback parameter should be a function that looks like this:
* function(object result) {...};
*/
export function settings(callback?: (result: SettingsCallback) => void): Promise<SettingsCallback>;
/**
* Clears plugins' data.
* @param callback Called when plugins' data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removePluginData(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears the browser's stored form data (autofill).
* @param callback Called when the browser's form data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeFormData(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears websites' file system data.
* @param callback Called when websites' file systems have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeFileSystems(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears various types of browsing data stored in a user's profile.
* @param dataToRemove The set of data types to remove.
* @param callback Called when deletion has completed.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function remove(options: RemovalOptions, dataToRemove: DataTypeSet, callback?: () => void): Promise<void>;
/**
* Clears the browser's stored passwords.
* @param callback Called when the browser's passwords have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removePasswords(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears the browser's cookies and server-bound certificates modified within a particular timeframe.
* @param callback Called when the browser's cookies and server-bound certificates have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeCookies(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears websites' WebSQL data.
* @param callback Called when websites' WebSQL databases have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeWebSQL(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears websites' appcache data.
* @param callback Called when websites' appcache data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeAppcache(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears the browser's list of downloaded files (not the downloaded files themselves).
* @param callback Called when the browser's list of downloaded files has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeDownloads(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears websites' local storage data.
* @param callback Called when websites' local storage has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeLocalStorage(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears the browser's cache.
* @param callback Called when the browser's cache has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeCache(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears the browser's history.
* @param callback Called when the browser's history has cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeHistory(options: RemovalOptions, callback?: () => void): Promise<void>;
/**
* Clears websites' IndexedDB data.
* @param callback Called when websites' IndexedDB data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeIndexedDB(options: RemovalOptions, callback?: () => void): Promise<void>;
}
////////////////////
// Commands
////////////////////
/**
* Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension.
* Availability: Since Chrome 25.
* Manifest: "commands": {...}
*/
declare namespace chrome.commands {
interface Command {
/** Optional. The name of the Extension Command */
name?: string;
/** Optional. The Extension Command description */
description?: string;
/** Optional. The shortcut active for this command, or blank if not active. */
shortcut?: string;
}
interface CommandEvent extends chrome.events.Event<(command: string) => void> { }
/**
* Returns all the registered extension commands for this extension and their shortcut (if active).
* @param callback Called to return the registered commands.
* If you specify the callback parameter, it should be a function that looks like this:
* function(array of Command commands) {...};
*/
export function getAll(callback?: (commands: Command[]) => void): Promise<Command[]>;
/** Fired when a registered command is activated using a keyboard shortcut. */
var onCommand: CommandEvent;
}
////////////////////
// Content Settings
////////////////////
/**
* Use the chrome.contentSettings API to change settings that control whether websites can use features such as cookies, JavaScript, and plugins. More generally speaking, content settings allow you to customize Chrome's behavior on a per-site basis instead of globally.
* Availability: Since Chrome 16.
* Permissions: "contentSettings"
*/
declare namespace chrome.contentSettings {
interface ClearDetails {
/**
* Optional.
* Where to clear the setting (default: regular).
* The scope of the ContentSetting. One of
* * regular: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere),
* * incognito_session_only: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular settings).
*/
scope?: string;
}
interface SetDetails {
/** Optional. The resource identifier for the content type. */
resourceIdentifier?: ResourceIdentifier;
/** The setting applied by this rule. See the description of the individual ContentSetting objects for the possible values. */
setting: any;
/** Optional. The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see Content Setting Patterns. */
secondaryPattern?: string;
/** Optional. Where to set the setting (default: regular). */
scope?: string;
/** The pattern for the primary URL. For details on the format of a pattern, see Content Setting Patterns. */
primaryPattern: string;
}
interface GetDetails {
/** Optional. The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs. */
secondaryUrl?: string;
/** Optional. A more specific identifier of the type of content for which the settings should be retrieved. */
resourceIdentifier?: ResourceIdentifier;
/** Optional. Whether to check the content settings for an incognito session. (default false) */
incognito?: boolean;
/** The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type. */
primaryUrl: string;
}
interface ReturnedDetails {
/** The content setting. See the description of the individual ContentSetting objects for the possible values. */
setting: any;
}
interface ContentSetting {
/**
* Clear all content setting rules set by this extension.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
clear(details: ClearDetails, callback?: () => void): Promise<void>;
/**
* Applies a new content setting rule.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
set(details: SetDetails, callback?: () => void): Promise<void>;
/**
* @param callback The callback parameter should be a function that looks like this:
* function(array of ResourceIdentifier resourceIdentifiers) {...};
* Parameter resourceIdentifiers: A list of resource identifiers for this content type, or undefined if this content type does not use resource identifiers.
*/
getResourceIdentifiers(callback?: (resourceIdentifiers?: ResourceIdentifier[]) => void): Promise<ResourceIdentifier[]>;
/**
* Gets the current content setting for a given pair of URLs.
* @param callback The callback parameter should be a function that looks like this:
* function(object details) {...};
*/
get(details: GetDetails, callback?: (details: ReturnedDetails) => void): Promise<ReturnedDetails>;
}
/** The only content type using resource identifiers is contentSettings.plugins. For more information, see Resource Identifiers. */
interface ResourceIdentifier {
/** The resource identifier for the given content type. */
id: string;
/** Optional. A human readable description of the resource. */
description?: string;
}
/**
* Whether to allow cookies and other local data to be set by websites. One of
* allow: Accept cookies,
* block: Block cookies,
* session_only: Accept cookies only for the current session.
* Default is allow.
* The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame.
*/
var cookies: ContentSetting;
/**
* Whether to allow sites to show pop-ups. One of
* allow: Allow sites to show pop-ups,
* block: Don't allow sites to show pop-ups.
* Default is block.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
var popups: ContentSetting;
/**
* Whether to run JavaScript. One of
* allow: Run JavaScript,
* block: Don't run JavaScript.
* Default is allow.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
var javascript: ContentSetting;
/**
* Whether to allow sites to show desktop notifications. One of
* allow: Allow sites to show desktop notifications,
* block: Don't allow sites to show desktop notifications,
* ask: Ask when a site wants to show desktop notifications.
* Default is ask.
* The primary URL is the URL of the document which wants to show the notification. The secondary URL is not used.
*/
var notifications: ContentSetting;
/**
* Whether to run plugins. One of
* allow: Run plugins automatically,
* block: Don't run plugins automatically,
* detect_important_content: Only run automatically those plugins that are detected as the website's main content.
* Default is allow.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
var plugins: ContentSetting;
/**
* Whether to show images. One of
* allow: Show images,
* block: Don't show images.
* Default is allow.
* The primary URL is the URL of the top-level frame. The secondary URL is the URL of the image.
*/
var images: ContentSetting;
/**
* Since Chrome 42.
* Whether to allow Geolocation. One of
* allow: Allow sites to track your physical location,
* block: Don't allow sites to track your physical location,
* ask: Ask before allowing sites to track your physical location.
* Default is ask.
* The primary URL is the URL of the document which requested location data. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL).
*/
var location: ContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to toggle the fullscreen mode. One of
* allow: Allow sites to toggle the fullscreen mode,
* ask: Ask when a site wants to toggle the fullscreen mode.
* Default is ask.
* The primary URL is the URL of the document which requested to toggle the fullscreen mode. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL).
*/
var fullscreen: ContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to disable the mouse cursor. One of
* allow: Allow sites to disable the mouse cursor,
* block: Don't allow sites to disable the mouse cursor,
* ask: Ask when a site wants to disable the mouse cursor.
* Default is ask.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
var mouselock: ContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to run plugins unsandboxed. One of
* allow: Allow sites to run plugins unsandboxed,
* block: Don't allow sites to run plugins unsandboxed,
* ask: Ask when a site wants to run a plugin unsandboxed.
* Default is ask.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
var unsandboxedPlugins: ContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to download multiple files automatically. One of
* allow: Allow sites to download multiple files automatically,
* block: Don't allow sites to download multiple files automatically,
* ask: Ask when a site wants to download files automatically after the first file.
* Default is ask.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
var automaticDownloads: ContentSetting;
}
////////////////////
// Context Menus
////////////////////
/**
* Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
* Availability: Since Chrome 6.
* Permissions: "contextMenus"
*/
declare namespace chrome.contextMenus {
interface OnClickData {
/**
* Optional.
* Since Chrome 35.
* The text for the context selection, if any.
*/
selectionText?: string;
/**
* Optional.
* Since Chrome 35.
* A flag indicating the state of a checkbox or radio item after it is clicked.
*/
checked?: boolean;
/**
* Since Chrome 35.
* The ID of the menu item that was clicked.
*/
menuItemId: any;
/**
* Optional.
* Since Chrome 35.
* The URL of the frame of the element where the context menu was clicked, if it was in a frame.
*/
frameUrl?: string;
/**
* Since Chrome 35.
* A flag indicating whether the element is editable (text input, textarea, etc.).
*/
editable: boolean;
/**
* Optional.
* Since Chrome 35.
* One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
*/
mediaType?: string;
/**
* Optional.
* Since Chrome 35.
* A flag indicating the state of a checkbox or radio item before it was clicked.
*/
wasChecked?: boolean;
/**
* Since Chrome 35.
* The URL of the page where the menu item was clicked. This property is not set if the click occured in a context where there is no current page, such as in a launcher context menu.
*/
pageUrl: string;
/**
* Optional.
* Since Chrome 35.
* If the element is a link, the URL it points to.
*/
linkUrl?: string;
/**
* Optional.
* Since Chrome 35.
* The parent ID, if any, for the item clicked.
*/
parentMenuItemId?: any;
/**