@types/chrome 0.0.330 → 0.0.331

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. chrome/README.md +1 -1
  2. chrome/index.d.ts +478 -813
  3. chrome/package.json +2 -2
chrome/index.d.ts CHANGED
@@ -11198,67 +11198,54 @@ declare namespace chrome {
11198
11198
  */
11199
11199
  export namespace tabs {
11200
11200
  /**
11201
- * Tab muted state and the reason for the last state change.
11201
+ * The tab's muted state and the reason for the last state change.
11202
11202
  * @since Chrome 46
11203
11203
  */
11204
11204
  export interface MutedInfo {
11205
- /** Whether the tab is prevented from playing sound (but hasn't necessarily recently produced sound). Equivalent to whether the muted audio indicator is showing. */
11205
+ /** Whether the tab is muted (prevented from playing sound). The tab may be muted even if it has not played or is not currently playing sound. Equivalent to whether the 'muted' audio indicator is showing. */
11206
11206
  muted: boolean;
11207
- /**
11208
- * Optional.
11209
- * The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed.
11210
- * "user": A user input action has set/overridden the muted state.
11211
- * "capture": Tab capture started, forcing a muted state change.
11212
- * "extension": An extension, identified by the extensionId field, set the muted state.
11213
- */
11214
- reason?: string | undefined;
11215
- /**
11216
- * Optional.
11217
- * The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed.
11218
- */
11207
+ /* The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed. */
11208
+ reason?: `${MutedInfoReason}` | undefined;
11209
+ /** The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed. */
11219
11210
  extensionId?: string | undefined;
11220
11211
  }
11221
11212
 
11213
+ /**
11214
+ * An event that caused a muted state change.
11215
+ * @since Chrome 46
11216
+ */
11217
+ export enum MutedInfoReason {
11218
+ /** A user input action set the muted state. */
11219
+ USER = "user",
11220
+ /** Tab capture was started, forcing a muted state change. */
11221
+ CAPTURE = "capture",
11222
+ /** An extension set the muted state. */
11223
+ EXTENSION = "extension",
11224
+ }
11225
+
11222
11226
  export interface Tab {
11223
- /**
11224
- * Optional.
11225
- * Either loading or complete.
11226
- */
11227
- status?: string | undefined;
11227
+ /** The tab's loading status. */
11228
+ status?: `${TabStatus}` | undefined;
11228
11229
  /** The zero-based index of the tab within its window. */
11229
11230
  index: number;
11230
- /**
11231
- * Optional.
11232
- * The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.
11233
- * @since Chrome 18
11234
- */
11231
+ /** The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists. */
11235
11232
  openerTabId?: number | undefined;
11236
- /** The title of the tab. This property is only present if the extension has the `tabs` permission or has host permissions for the page. */
11233
+ /** The title of the tab. This property is only present if the extension has the `"tabs"` permission or has host permissions for the page. */
11237
11234
  title?: string | undefined;
11238
- /** The last committed URL of the main frame of the tab. This property is only present if the extension has the `tabs` permission or has host permissions for the page. May be an empty string if the tab has not yet committed. See also {@link Tab.pendingUrl}. */
11235
+ /** The last committed URL of the main frame of the tab. This property is only present if the extension has the `"tabs"` permission or has host permissions for the page. May be an empty string if the tab has not yet committed. See also {@link Tab.pendingUrl}. */
11239
11236
  url?: string | undefined;
11240
11237
  /**
11241
- * The URL the tab is navigating to, before it has committed. This property is only present if the extension has the `tabs` permission or has host permissions for the page and there is a pending navigation.The URL the tab is navigating to, before it has committed.
11242
- * This property is only present if the extension's manifest includes the "tabs" permission and there is a pending navigation.
11238
+ * The URL the tab is navigating to, before it has committed. This property is only present if the extension has the `"tabs"` permission or has host permissions for the page and there is a pending navigation.
11243
11239
  * @since Chrome 79
11244
11240
  */
11245
11241
  pendingUrl?: string | undefined;
11246
- /**
11247
- * Whether the tab is pinned.
11248
- * @since Chrome 9
11249
- */
11242
+ /** Whether the tab is pinned. */
11250
11243
  pinned: boolean;
11251
- /**
11252
- * Whether the tab is highlighted.
11253
- * @since Chrome 16
11254
- */
11244
+ /** Whether the tab is highlighted. */
11255
11245
  highlighted: boolean;
11256
- /** The ID of the window the tab is contained within. */
11246
+ /** The ID of the window that contains the tab. */
11257
11247
  windowId: number;
11258
- /**
11259
- * Whether the tab is active in its window. (Does not necessarily mean the window is focused.)
11260
- * @since Chrome 16
11261
- */
11248
+ /** Whether the tab is active in its window. Does not necessarily mean the window is focused. */
11262
11249
  active: boolean;
11263
11250
  /** The URL of the tab's favicon. This property is only present if the extension has the `tabs` permission or has host permissions for the page. It may also be an empty string if the tab is loading. */
11264
11251
  favIconUrl?: string | undefined;
@@ -11267,26 +11254,22 @@ declare namespace chrome {
11267
11254
  * @since Chrome 132
11268
11255
  */
11269
11256
  frozen: boolean;
11270
- /**
11271
- * Optional.
11272
- * The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a Tab may not be assigned an ID, for example when querying foreign tabs using the sessions API, in which case a session ID may be present. Tab ID can also be set to chrome.tabs.TAB_ID_NONE for apps and devtools windows.
11273
- */
11257
+ /** The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a tab may not be assigned an ID; for example, when querying foreign tabs using the {@link sessions} API, in which case a session ID may be present. Tab ID can also be set to `chrome.tabs.TAB_ID_NONE` for apps and devtools windows. */
11274
11258
  id?: number | undefined;
11275
11259
  /** Whether the tab is in an incognito window. */
11276
11260
  incognito: boolean;
11277
11261
  /**
11278
11262
  * Whether the tab is selected.
11279
- * @deprecated since Chrome 33. Please use tabs.Tab.highlighted.
11263
+ * @deprecated since Chrome 33. Please use {@link Tab.highlighted}.
11280
11264
  */
11281
11265
  selected: boolean;
11282
11266
  /**
11283
- * Optional.
11284
- * Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted). Equivalent to whether the speaker audio indicator is showing.
11267
+ * Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted). Equivalent to whether the 'speaker audio' indicator is showing.
11285
11268
  * @since Chrome 45
11286
11269
  */
11287
11270
  audible?: boolean | undefined;
11288
11271
  /**
11289
- * Whether the tab is discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content gets reloaded the next time it's activated.
11272
+ * Whether the tab is discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content is reloaded the next time it is activated.
11290
11273
  * @since Chrome 54
11291
11274
  */
11292
11275
  discarded: boolean;
@@ -11296,25 +11279,15 @@ declare namespace chrome {
11296
11279
  */
11297
11280
  autoDiscardable: boolean;
11298
11281
  /**
11299
- * Optional.
11300
- * Current tab muted state and the reason for the last state change.
11282
+ * The tab's muted state and the reason for the last state change.
11301
11283
  * @since Chrome 46
11302
11284
  */
11303
11285
  mutedInfo?: MutedInfo | undefined;
11304
- /**
11305
- * Optional. The width of the tab in pixels.
11306
- * @since Chrome 31
11307
- */
11286
+ /** The width of the tab in pixels. */
11308
11287
  width?: number | undefined;
11309
- /**
11310
- * Optional. The height of the tab in pixels.
11311
- * @since Chrome 31
11312
- */
11288
+ /** The height of the tab in pixels. */
11313
11289
  height?: number | undefined;
11314
- /**
11315
- * Optional. The session ID used to uniquely identify a Tab obtained from the sessions API.
11316
- * @since Chrome 31
11317
- */
11290
+ /** The session ID used to uniquely identify a tab obtained from the {@link sessions} API. */
11318
11291
  sessionId?: string | undefined;
11319
11292
  /**
11320
11293
  * The ID of the group that the tab belongs to.
@@ -11328,203 +11301,201 @@ declare namespace chrome {
11328
11301
  lastAccessed?: number | undefined;
11329
11302
  }
11330
11303
 
11331
- /**
11332
- * Defines how zoom changes in a tab are handled and at what scope.
11333
- * @since Chrome 38
11334
- */
11304
+ /** The tab's loading status. */
11305
+ export enum TabStatus {
11306
+ UNLOADED = "unloaded",
11307
+ LOADING = "loading",
11308
+ COMPLETE = "complete",
11309
+ }
11310
+
11311
+ /** The type of window. */
11312
+ export enum WindowType {
11313
+ NORMAL = "normal",
11314
+ POPUP = "popup",
11315
+ PANEL = "panel",
11316
+ APP = "app",
11317
+ DEVTOOLS = "devtools",
11318
+ }
11319
+
11320
+ /** Defines how zoom changes in a tab are handled and at what scope. */
11335
11321
  export interface ZoomSettings {
11322
+ /** Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to `automatic`. */
11323
+ mode?: `${ZoomSettingsMode}` | undefined;
11324
+ /** Defines whether zoom changes persist for the page's origin, or only take effect in this tab; defaults to `per-origin` when in `automatic` mode, and `per-tab` otherwise. */
11325
+ scope?: `${ZoomSettingsScope}` | undefined;
11336
11326
  /**
11337
- * Optional.
11338
- * Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to "automatic".
11339
- * "automatic": Zoom changes are handled automatically by the browser.
11340
- * "manual": Overrides the automatic handling of zoom changes. The onZoomChange event will still be dispatched, and it is the responsibility of the extension to listen for this event and manually scale the page. This mode does not support per-origin zooming, and will thus ignore the scope zoom setting and assume per-tab.
11341
- * "disabled": Disables all zooming in the tab. The tab will revert to the default zoom level, and all attempted zoom changes will be ignored.
11342
- */
11343
- mode?: string | undefined;
11344
- /**
11345
- * Optional.
11346
- * Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise.
11347
- * "per-origin": Zoom changes will persist in the zoomed page's origin, i.e. all other tabs navigated to that same origin will be zoomed as well. Moreover, per-origin zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they will all be zoomed to the same zoom factor. The per-origin scope is only available in the automatic mode.
11348
- * "per-tab": Zoom changes only take effect in this tab, and zoom changes in other tabs will not affect the zooming of this tab. Also, per-tab zoom changes are reset on navigation; navigating a tab will always load pages with their per-origin zoom factors.
11349
- */
11350
- scope?: string | undefined;
11351
- /**
11352
- * Optional.
11353
- * Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings.
11327
+ * Used to return the default zoom level for the current tab in calls to {@link tabs.getZoomSettings}.
11354
11328
  * @since Chrome 43
11355
11329
  */
11356
11330
  defaultZoomFactor?: number | undefined;
11357
11331
  }
11358
11332
 
11333
+ /**
11334
+ * Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to `automatic`.
11335
+ * @since Chrome 44
11336
+ */
11337
+ export enum ZoomSettingsMode {
11338
+ /** Zoom changes are handled automatically by the browser. */
11339
+ AUTOMATIC = "automatic",
11340
+ /** Overrides the automatic handling of zoom changes. The `onZoomChange` event will still be dispatched, and it is the extension's responsibility to listen for this event and manually scale the page. This mode does not support `per-origin` zooming, and thus ignores the `scope` zoom setting and assumes `per-tab`. */
11341
+ MANUAL = "manual",
11342
+ /** Disables all zooming in the tab. The tab reverts to the default zoom level, and all attempted zoom changes are ignored. */
11343
+ DISABLED = "disabled",
11344
+ }
11345
+
11346
+ /**
11347
+ * Defines whether zoom changes persist for the page's origin, or only take effect in this tab; defaults to `per-origin` when in `automatic` mode, and `per-tab` otherwise.
11348
+ * @since Chrome 44
11349
+ */
11350
+ export enum ZoomSettingsScope {
11351
+ /** Zoom changes persist in the zoomed page's origin, i.e., all other tabs navigated to that same origin are zoomed as well. Moreover, `per-origin` zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they are all zoomed to the same zoom factor. The `per-origin` scope is only available in the `automatic` mode. */
11352
+ PER_ORIGIN = "per-origin",
11353
+ /** Zoom changes only take effect in this tab, and zoom changes in other tabs do not affect the zooming of this tab. Also, `per-tab` zoom changes are reset on navigation; navigating a tab always loads pages with their `per-origin` zoom factors. */
11354
+ PER_TAB = "per-tab",
11355
+ }
11356
+
11357
+ /**
11358
+ * The maximum number of times that {@link captureVisibleTab} can be called per second. {@link captureVisibleTab} is expensive and should not be called too often.
11359
+ * @since Chrome 92
11360
+ */
11361
+ export const MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND = 2;
11362
+
11363
+ /**
11364
+ * An ID that represents the absence of a browser tab.
11365
+ * @since Chrome 46
11366
+ */
11367
+ export const TAB_ID_NONE = -1;
11368
+
11369
+ /**
11370
+ * An index that represents the absence of a tab index in a tab_strip.
11371
+ * @since Chrome 123
11372
+ */
11373
+ export const TAB_INDEX_NONE = -1;
11374
+
11359
11375
  export interface CreateProperties {
11360
- /** Optional. The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window. */
11376
+ /** The position the tab should take in the window. The provided value is clamped to between zero and the number of tabs in the window. */
11361
11377
  index?: number | undefined;
11362
- /**
11363
- * Optional.
11364
- * The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.
11365
- * @since Chrome 18
11366
- */
11378
+ /** The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab. */
11367
11379
  openerTabId?: number | undefined;
11368
- /**
11369
- * Optional.
11370
- * The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page.
11371
- */
11380
+ /** The URL to initially navigate the tab to. Fully-qualified URLs must include a scheme (i.e., 'http://www.google.com', not 'www.google.com'). Relative URLs are relative to the current page within the extension. Defaults to the New Tab Page. */
11372
11381
  url?: string | undefined;
11373
- /**
11374
- * Optional. Whether the tab should be pinned. Defaults to false
11375
- * @since Chrome 9
11376
- */
11382
+ /** Whether the tab should be pinned. Defaults to `false` */
11377
11383
  pinned?: boolean | undefined;
11378
- /** Optional. The window to create the new tab in. Defaults to the current window. */
11384
+ /** The window in which to create the new tab. Defaults to the current window. */
11379
11385
  windowId?: number | undefined;
11380
- /**
11381
- * Optional.
11382
- * Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see windows.update). Defaults to true.
11383
- * @since Chrome 16
11384
- */
11386
+ /** Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see {@link windows.update}). Defaults to `true`. */
11385
11387
  active?: boolean | undefined;
11386
11388
  /**
11387
- * Optional. Whether the tab should become the selected tab in the window. Defaults to true
11388
- * @deprecated since Chrome 33. Please use active.
11389
+ * Whether the tab should become the selected tab in the window. Defaults to `true`
11390
+ * @deprecated since Chrome 33. Please use {@link CreateProperties.active active}.
11389
11391
  */
11390
11392
  selected?: boolean | undefined;
11391
11393
  }
11392
11394
 
11393
11395
  export interface MoveProperties {
11394
- /** The position to move the window to. -1 will place the tab at the end of the window. */
11396
+ /** The position to move the window to. Use `-1` to place the tab at the end of the window. */
11395
11397
  index: number;
11396
- /** Optional. Defaults to the window the tab is currently in. */
11398
+ /** Defaults to the window the tab is currently in. */
11397
11399
  windowId?: number | undefined;
11398
11400
  }
11399
11401
 
11400
11402
  export interface UpdateProperties {
11401
- /**
11402
- * Optional. Whether the tab should be pinned.
11403
- * @since Chrome 9
11404
- */
11403
+ /** Whether the tab should be pinned. */
11405
11404
  pinned?: boolean | undefined;
11406
- /**
11407
- * Optional. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.
11408
- * @since Chrome 18
11409
- */
11405
+ /** The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab. */
11410
11406
  openerTabId?: number | undefined;
11411
- /** Optional. A URL to navigate the tab to. */
11407
+ /** A URL to navigate the tab to. JavaScript URLs are not supported; use {@link scripting.executeScript} instead. */
11412
11408
  url?: string | undefined;
11413
- /**
11414
- * Optional. Adds or removes the tab from the current selection.
11415
- * @since Chrome 16
11416
- */
11409
+ /** Adds or removes the tab from the current selection. */
11417
11410
  highlighted?: boolean | undefined;
11418
- /**
11419
- * Optional. Whether the tab should be active. Does not affect whether the window is focused (see windows.update).
11420
- * @since Chrome 16
11421
- */
11411
+ /** Whether the tab should be active. Does not affect whether the window is focused (see {@link windows.update}).*/
11422
11412
  active?: boolean | undefined;
11423
11413
  /**
11424
- * Optional. Whether the tab should be selected.
11425
- * @deprecated since Chrome 33. Please use highlighted.
11414
+ * Whether the tab should be selected.
11415
+ * @deprecated since Chrome 33. Please use {@link highlighted}.
11426
11416
  */
11427
11417
  selected?: boolean | undefined;
11428
11418
  /**
11429
- * Optional. Whether the tab should be muted.
11419
+ * Whether the tab should be muted.
11430
11420
  * @since Chrome 45
11431
11421
  */
11432
11422
  muted?: boolean | undefined;
11433
11423
  /**
11434
- * Optional. Whether the tab should be discarded automatically by the browser when resources are low.
11424
+ * Whether the tab should be discarded automatically by the browser when resources are low.
11435
11425
  * @since Chrome 54
11436
11426
  */
11437
11427
  autoDiscardable?: boolean | undefined;
11438
11428
  }
11439
11429
 
11440
11430
  export interface ReloadProperties {
11441
- /** Optional. Whether using any local cache. Default is false. */
11431
+ /** Whether to bypass local caching. Defaults to `false`. */
11442
11432
  bypassCache?: boolean | undefined;
11443
11433
  }
11444
11434
 
11445
11435
  export interface ConnectInfo {
11446
- /** Optional. Will be passed into onConnect for content scripts that are listening for the connection event. */
11436
+ /** Is passed into onConnect for content scripts that are listening for the connection event. */
11447
11437
  name?: string | undefined;
11448
- /**
11449
- * Open a port to a specific frame identified by frameId instead of all frames in the tab.
11450
- * @since Chrome 41
11451
- */
11438
+ /** Open a port to a specific frame identified by `frameId` instead of all frames in the tab. */
11452
11439
  frameId?: number | undefined;
11453
11440
  /**
11454
- * Optional. Open a port to a specific document identified by documentId instead of all frames in the tab.
11441
+ * Open a port to a specific document identified by `documentId` instead of all frames in the tab.
11455
11442
  * @since Chrome 106
11456
11443
  */
11457
11444
  documentId?: string;
11458
11445
  }
11459
11446
 
11460
11447
  export interface MessageSendOptions {
11461
- /** Optional. Send a message to a specific frame identified by frameId instead of all frames in the tab. */
11448
+ /** Send a message to a specific frame identified by `frameId` instead of all frames in the tab. */
11462
11449
  frameId?: number | undefined;
11463
11450
  /**
11464
- * Optional. Send a message to a specific document identified by documentId instead of all frames in the tab.
11451
+ * Send a message to a specific document identified by `documentId` instead of all frames in the tab.
11465
11452
  * @since Chrome 106
11466
11453
  */
11467
11454
  documentId?: string;
11468
11455
  }
11469
11456
 
11470
11457
  export interface GroupOptions {
11471
- /** Optional. Configurations for creating a group. Cannot be used if groupId is already specified. */
11458
+ /** Configurations for creating a group. Cannot be used if groupId is already specified. */
11472
11459
  createProperties?: {
11473
- /** Optional. The window of the new group. Defaults to the current window. */
11460
+ /** The window of the new group. Defaults to the current window. */
11474
11461
  windowId?: number | undefined;
11475
11462
  } | undefined;
11476
- /** Optional. The ID of the group to add the tabs to. If not specified, a new group will be created. */
11463
+ /** The ID of the group to add the tabs to. If not specified, a new group will be created. */
11477
11464
  groupId?: number | undefined;
11478
- /** TOptional. he tab ID or list of tab IDs to add to the specified group. */
11479
- tabIds?: number | number[] | undefined;
11465
+ /** The tab ID or list of tab IDs to add to the specified group. */
11466
+ tabIds?: number | [number, ...number[]] | undefined;
11480
11467
  }
11481
11468
 
11482
11469
  export interface HighlightInfo {
11483
11470
  /** One or more tab indices to highlight. */
11484
11471
  tabs: number | number[];
11485
- /** Optional. The window that contains the tabs. */
11472
+ /** The window that contains the tabs. */
11486
11473
  windowId?: number | undefined;
11487
11474
  }
11488
11475
 
11489
11476
  export interface QueryInfo {
11490
- /**
11491
- * Optional. Whether the tabs have completed loading.
11492
- * One of: "loading", or "complete"
11493
- */
11494
- status?: "loading" | "complete" | undefined;
11495
- /**
11496
- * Optional. Whether the tabs are in the last focused window.
11497
- * @since Chrome 19
11498
- */
11477
+ /** The tab loading status. */
11478
+ status?: `${TabStatus}` | undefined;
11479
+ /** Whether the tabs are in the last focused window. */
11499
11480
  lastFocusedWindow?: boolean | undefined;
11500
- /** Optional. The ID of the parent window, or windows.WINDOW_ID_CURRENT for the current window. */
11481
+ /** The ID of the parent window, or {@link windows.WINDOW_ID_CURRENT} for the current window. */
11501
11482
  windowId?: number | undefined;
11502
- /**
11503
- * Optional. The type of window the tabs are in.
11504
- * One of: "normal", "popup", "panel", "app", or "devtools"
11505
- */
11506
- windowType?: "normal" | "popup" | "panel" | "app" | "devtools" | undefined;
11507
- /** Optional. Whether the tabs are active in their windows. */
11483
+ /** The type of window the tabs are in. */
11484
+ windowType?: `${WindowType}` | undefined;
11485
+ /** Whether the tabs are active in their windows. */
11508
11486
  active?: boolean | undefined;
11509
- /**
11510
- * Optional. The position of the tabs within their windows.
11511
- * @since Chrome 18
11512
- */
11487
+ /** The position of the tabs within their windows. */
11513
11488
  index?: number | undefined;
11514
- /** Match page titles against a pattern. This property is ignored if the extension does not have the `tabs` permission or host permissions for the page. */
11489
+ /** Match page titles against a pattern. This property is ignored if the extension does not have the `"tabs"` permission or host permissions for the page. */
11515
11490
  title?: string | undefined;
11516
- /** Match tabs against one or more URL patterns. Fragment identifiers are not matched. This property is ignored if the extension does not have the `tabs` permission or host permissions for the page. */
11491
+ /** Match tabs against one or more URL patterns. Fragment identifiers are not matched. This property is ignored if the extension does not have the `"tabs"` permission or host permissions for the page. */
11517
11492
  url?: string | string[] | undefined;
11518
- /**
11519
- * Optional. Whether the tabs are in the current window.
11520
- * @since Chrome 19
11521
- */
11493
+ /** Whether the tabs are in the current window. */
11522
11494
  currentWindow?: boolean | undefined;
11523
- /** Optional. Whether the tabs are highlighted. */
11495
+ /** Whether the tabs are highlighted. */
11524
11496
  highlighted?: boolean | undefined;
11525
11497
  /**
11526
- * Optional.
11527
- * Whether the tabs are discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content gets reloaded the next time it's activated.
11498
+ * Whether the tabs are discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content is reloaded the next time it is activated.
11528
11499
  * @since Chrome 54
11529
11500
  */
11530
11501
  discarded?: boolean | undefined;
@@ -11532,866 +11503,560 @@ declare namespace chrome {
11532
11503
  * Whether the tabs are frozen. A frozen tab cannot execute tasks, including event handlers or timers. It is visible in the tab strip and its content is loaded in memory. It is unfrozen on activation.
11533
11504
  * @since Chrome 132
11534
11505
  */
11535
- frozen?: boolean;
11506
+ frozen?: boolean | undefined;
11536
11507
  /**
11537
- * Optional.
11538
11508
  * Whether the tabs can be discarded automatically by the browser when resources are low.
11539
11509
  * @since Chrome 54
11540
11510
  */
11541
11511
  autoDiscardable?: boolean | undefined;
11542
- /** Optional. Whether the tabs are pinned. */
11512
+ /** Whether the tabs are pinned. */
11543
11513
  pinned?: boolean | undefined;
11544
11514
  /**
11545
- * Optional. Whether the tabs are audible.
11515
+ * Whether the tabs are audible.
11546
11516
  * @since Chrome 45
11547
11517
  */
11548
11518
  audible?: boolean | undefined;
11549
11519
  /**
11550
- * Optional. Whether the tabs are muted.
11520
+ * Whether the tabs are muted.
11551
11521
  * @since Chrome 45
11552
11522
  */
11553
11523
  muted?: boolean | undefined;
11554
11524
  /**
11555
- * Optional. The ID of the group that the tabs are in, or chrome.tabGroups.TAB_GROUP_ID_NONE for ungrouped tabs.
11525
+ * The ID of the group that the tabs are in, or {@link chrome.tabGroups.TAB_GROUP_ID_NONE} for ungrouped tabs.
11556
11526
  * @since Chrome 88
11557
11527
  */
11558
11528
  groupId?: number | undefined;
11559
11529
  }
11560
11530
 
11561
- export interface TabHighlightInfo {
11562
- windowId: number;
11531
+ export interface OnHighlightedInfo {
11532
+ /** All highlighted tabs in the window. */
11563
11533
  tabIds: number[];
11564
- }
11565
-
11566
- export interface TabRemoveInfo {
11567
- /**
11568
- * The window whose tab is closed.
11569
- * @since Chrome 25
11570
- */
11534
+ /** The window whose tabs changed. */
11571
11535
  windowId: number;
11572
- /** True when the tab is being closed because its window is being closed. */
11573
- isWindowClosing: boolean;
11574
11536
  }
11575
11537
 
11576
- export interface TabAttachInfo {
11577
- newPosition: number;
11578
- newWindowId: number;
11538
+ export interface OnRemovedInfo {
11539
+ /** True when the tab was closed because its parent window was closed. */
11540
+ isWindowClosing: boolean;
11541
+ /** The window whose tab is closed */
11542
+ windowId: number;
11579
11543
  }
11580
11544
 
11581
- export interface TabChangeInfo {
11582
- /** Optional. The status of the tab. Can be either loading or complete. */
11583
- status?: string | undefined;
11584
- /**
11585
- * The tab's new pinned state.
11586
- * @since Chrome 9
11587
- */
11588
- pinned?: boolean | undefined;
11589
- /** Optional. The tab's URL if it has changed. */
11590
- url?: string | undefined;
11545
+ export interface OnUpdatedInfo {
11546
+ /** The tab's new audible state. */
11547
+ audible?: boolean;
11591
11548
  /**
11592
- * The tab's new audible state.
11593
- * @since Chrome 45
11549
+ * The tab's new auto-discardable state.
11550
+ * @since Chrome 54
11594
11551
  */
11595
- audible?: boolean | undefined;
11552
+ autoDiscardable?: boolean;
11596
11553
  /**
11597
11554
  * The tab's new discarded state.
11598
11555
  * @since Chrome 54
11599
11556
  */
11600
- discarded?: boolean | undefined;
11557
+ discarded?: boolean;
11558
+ /** The tab's new favicon URL. */
11559
+ favIconUrl?: string;
11601
11560
  /**
11602
- * The tab's new auto-discardable
11603
- * @since Chrome 54
11561
+ * The tab's new frozen state.
11562
+ * @since Chrome 132
11604
11563
  */
11605
- autoDiscardable?: boolean | undefined;
11564
+ frozen?: boolean;
11606
11565
  /**
11607
11566
  * The tab's new group.
11608
11567
  * @since Chrome 88
11609
11568
  */
11610
- groupId?: number | undefined;
11569
+ groupId?: number;
11611
11570
  /**
11612
11571
  * The tab's new muted state and the reason for the change.
11613
11572
  * @since Chrome 46
11614
11573
  */
11615
- mutedInfo?: MutedInfo | undefined;
11616
- /**
11617
- * The tab's new favicon URL.
11618
- * @since Chrome 27
11619
- */
11620
- favIconUrl?: string | undefined;
11621
- /**
11622
- * The tab's new frozen state.
11623
- * @since Chrome 132
11624
- */
11625
- frozen?: boolean;
11574
+ mutedInfo?: MutedInfo;
11575
+ /** The tab's new pinned state. */
11576
+ pinned?: boolean;
11577
+ /** The tab's loading status. */
11578
+ status?: `${TabStatus}`;
11626
11579
  /**
11627
11580
  * The tab's new title.
11628
11581
  * @since Chrome 48
11629
11582
  */
11630
- title?: string | undefined;
11583
+ title?: string;
11584
+ /** The tab's URL if it has changed. */
11585
+ url?: string;
11586
+ }
11587
+
11588
+ export interface OnAttachedInfo {
11589
+ newPosition: number;
11590
+ newWindowId: number;
11631
11591
  }
11632
11592
 
11633
- export interface TabMoveInfo {
11593
+ export interface OnMovedInfo {
11594
+ fromIndex: number;
11634
11595
  toIndex: number;
11635
11596
  windowId: number;
11636
- fromIndex: number;
11637
11597
  }
11638
11598
 
11639
- export interface TabDetachInfo {
11640
- oldWindowId: number;
11599
+ export interface OnDetachedInfo {
11641
11600
  oldPosition: number;
11601
+ oldWindowId: number;
11642
11602
  }
11643
11603
 
11644
- export interface TabActiveInfo {
11604
+ export interface OnActivatedInfo {
11645
11605
  /** The ID of the tab that has become active. */
11646
11606
  tabId: number;
11647
11607
  /** The ID of the window the active tab changed inside of. */
11648
11608
  windowId: number;
11649
11609
  }
11650
11610
 
11651
- export interface TabWindowInfo {
11652
- /** The ID of the window of where the tab is located. */
11611
+ export interface OnSelectionChangedInfo {
11612
+ /** The ID of the window the selected tab changed inside of. */
11653
11613
  windowId: number;
11654
11614
  }
11655
11615
 
11656
- export interface ZoomChangeInfo {
11657
- tabId: number;
11658
- oldZoomFactor: number;
11659
- newZoomFactor: number;
11660
- zoomSettings: ZoomSettings;
11616
+ export interface OnActiveChangedInfo {
11617
+ /** The ID of the window the selected tab changed inside of. */
11618
+ windowId: number;
11661
11619
  }
11662
11620
 
11663
- export interface TabHighlightedEvent extends chrome.events.Event<(highlightInfo: TabHighlightInfo) => void> {}
11664
-
11665
- export interface TabRemovedEvent
11666
- extends chrome.events.Event<(tabId: number, removeInfo: TabRemoveInfo) => void>
11667
- {}
11668
-
11669
- export interface TabUpdatedEvent
11670
- extends chrome.events.Event<(tabId: number, changeInfo: TabChangeInfo, tab: Tab) => void>
11671
- {}
11672
-
11673
- export interface TabAttachedEvent
11674
- extends chrome.events.Event<(tabId: number, attachInfo: TabAttachInfo) => void>
11675
- {}
11676
-
11677
- export interface TabMovedEvent extends chrome.events.Event<(tabId: number, moveInfo: TabMoveInfo) => void> {}
11678
-
11679
- export interface TabDetachedEvent
11680
- extends chrome.events.Event<(tabId: number, detachInfo: TabDetachInfo) => void>
11681
- {}
11682
-
11683
- export interface TabCreatedEvent extends chrome.events.Event<(tab: Tab) => void> {}
11684
-
11685
- export interface TabActivatedEvent extends chrome.events.Event<(activeInfo: TabActiveInfo) => void> {}
11686
-
11687
- export interface TabReplacedEvent
11688
- extends chrome.events.Event<(addedTabId: number, removedTabId: number) => void>
11689
- {}
11690
-
11691
- export interface TabSelectedEvent
11692
- extends chrome.events.Event<(tabId: number, selectInfo: TabWindowInfo) => void>
11693
- {}
11621
+ export interface OnHighlightChangedInfo {
11622
+ /** All highlighted tabs in the window. */
11623
+ tabIds: number[];
11624
+ /** The window whose tabs changed. */
11625
+ windowId: number;
11626
+ }
11694
11627
 
11695
- export interface TabZoomChangeEvent extends chrome.events.Event<(ZoomChangeInfo: ZoomChangeInfo) => void> {}
11628
+ export interface OnZoomChangeInfo {
11629
+ newZoomFactor: number;
11630
+ oldZoomFactor: number;
11631
+ tabId: number;
11632
+ zoomSettings: ZoomSettings;
11633
+ }
11696
11634
 
11697
11635
  /**
11698
11636
  * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11699
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
11700
- * @return The `executeScript` method provides its result via callback or returned as a `Promise` (MV3 only). The result of the script in every injected frame.
11701
- */
11702
- export function executeScript(details: extensionTypes.InjectDetails): Promise<any[]>;
11703
- /**
11704
- * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11705
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
11706
- * @param callback Optional. Called after all the JavaScript has been executed.
11707
- * Parameter result: The result of the script in every injected frame.
11708
- */
11709
- export function executeScript(details: extensionTypes.InjectDetails, callback?: (result: any[]) => void): void;
11710
- /**
11711
- * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11712
- * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window.
11713
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
11714
- * @return The `executeScript` method provides its result via callback or returned as a `Promise` (MV3 only). The result of the script in every injected frame.
11715
- */
11716
- export function executeScript(tabId: number, details: extensionTypes.InjectDetails): Promise<any[]>;
11717
- /**
11718
- * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11719
- * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window.
11720
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
11721
- * @param callback Optional. Called after all the JavaScript has been executed.
11722
- * Parameter result: The result of the script in every injected frame.
11637
+ *
11638
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11639
+ *
11640
+ * MV2 only
11641
+ * @param tabId The ID of the tab in which to run the script; defaults to the active tab of the current window.
11642
+ * @param details Details of the script to run. Either the code or the file property must be set, but both may not be set at the same time
11643
+ * @deprecated since Chrome 99. Replaced by {@link scripting.executeScript} in Manifest V3.
11723
11644
  */
11645
+ export function executeScript(details: extensionTypes.InjectDetails): Promise<any[] | undefined>;
11724
11646
  export function executeScript(
11725
- tabId: number,
11647
+ tabId: number | undefined,
11648
+ details: extensionTypes.InjectDetails,
11649
+ ): Promise<any[] | undefined>;
11650
+ export function executeScript(details: extensionTypes.InjectDetails, callback: (result?: any[]) => void): void;
11651
+ export function executeScript(
11652
+ tabId: number | undefined,
11726
11653
  details: extensionTypes.InjectDetails,
11727
- callback?: (result: any[]) => void,
11654
+ callback: (result?: any[]) => void,
11728
11655
  ): void;
11729
- /** Retrieves details about the specified tab. */
11730
- export function get(tabId: number, callback: (tab: Tab) => void): void;
11656
+
11731
11657
  /**
11732
- * Retrieves details about the specified tab.
11733
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
11658
+ * Retrieves details about the specified tab
11659
+ *
11660
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11734
11661
  */
11735
11662
  export function get(tabId: number): Promise<Tab>;
11663
+ export function get(tabId: number, callback: (tab: Tab) => void): void;
11664
+
11736
11665
  /**
11737
11666
  * Gets details about all tabs in the specified window.
11738
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11739
- */
11740
- export function getAllInWindow(callback: (tab: Tab) => void): void;
11741
- /**
11742
- * Gets details about all tabs in the specified window.
11743
- * @return The `getAllInWindow` method provides its result via callback or returned as a `Promise` (MV3 only).
11744
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11745
- */
11746
- export function getAllInWindow(): Promise<Tab>;
11747
- /**
11748
- * Gets details about all tabs in the specified window.
11749
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11750
- * @param windowId Optional. Defaults to the current window.
11751
- */
11752
- export function getAllInWindow(windowId: number, callback: (tab: Tab) => void): void;
11753
- /**
11754
- * Gets details about all tabs in the specified window.
11755
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11756
- * @param windowId Optional. Defaults to the current window.
11757
- * @return The `getAllInWindow` method provides its result via callback or returned as a `Promise` (MV3 only).
11667
+ *
11668
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11669
+ *
11670
+ * MV2 only
11671
+ * @deprecated Please use {@link tabs.query} `{windowId: windowId}`.
11758
11672
  */
11759
- export function getAllInWindow(windowId: number): Promise<Tab>;
11760
- /** Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view). */
11761
- export function getCurrent(callback: (tab?: Tab) => void): void;
11673
+ export function getAllInWindow(windowId?: number): Promise<Tab[]>;
11674
+ export function getAllInWindow(callback: (tabs: Tab[]) => void): void;
11675
+ export function getAllInWindow(windowId: number | undefined, callback: (tabs: Tab[]) => void): void;
11676
+
11762
11677
  /**
11763
- * Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).
11764
- * @return The `getCurrent` method provides its result via callback or returned as a `Promise` (MV3 only).
11678
+ * Gets the tab that this script call is being made from. Returns `undefined` if called from a non-tab context (for example, a background page or popup view).
11679
+ *
11680
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11765
11681
  */
11766
11682
  export function getCurrent(): Promise<Tab | undefined>;
11683
+ export function getCurrent(callback: (tab?: Tab) => void): void;
11684
+
11767
11685
  /**
11768
11686
  * Gets the tab that is selected in the specified window.
11769
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11687
+ *
11688
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11689
+ *
11690
+ * MV2 only
11691
+ * @param windowId Defaults to the current window.
11692
+ * @deprecated Please use {@link tabs.query} `{active: true}`.
11770
11693
  */
11694
+ export function getSelected(windowId?: number): Promise<Tab>;
11771
11695
  export function getSelected(callback: (tab: Tab) => void): void;
11772
- /**
11773
- * Gets the tab that is selected in the specified window.
11774
- * @return The `getSelected` method provides its result via callback or returned as a `Promise` (MV3 only).
11775
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11776
- */
11777
- export function getSelected(): Promise<Tab>;
11778
- /**
11779
- * Gets the tab that is selected in the specified window.
11780
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11781
- * @param windowId Optional. Defaults to the current window.
11782
- */
11783
- export function getSelected(windowId: number, callback: (tab: Tab) => void): void;
11784
- /**
11785
- * Gets the tab that is selected in the specified window.
11786
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11787
- * @param windowId Optional. Defaults to the current window.
11788
- * @return The `getSelected` method provides its result via callback or returned as a `Promise` (MV3 only).
11789
- */
11790
- export function getSelected(windowId: number): Promise<Tab>;
11696
+ export function getSelected(windowId: number | undefined, callback: (tab: Tab) => void): void;
11697
+
11791
11698
  /**
11792
11699
  * Creates a new tab.
11793
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the created tab. Will contain the ID of the new tab.
11700
+ *
11701
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11794
11702
  */
11795
11703
  export function create(createProperties: CreateProperties): Promise<Tab>;
11796
- /**
11797
- * Creates a new tab.
11798
- * @param callback Optional.
11799
- * Parameter tab: Details about the created tab. Will contain the ID of the new tab.
11800
- */
11801
11704
  export function create(createProperties: CreateProperties, callback: (tab: Tab) => void): void;
11705
+
11802
11706
  /**
11803
11707
  * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
11804
- * @param tabId The tab to move.
11805
- * @return The `move` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the moved tab.
11708
+ * @param tabId The tab ID to move.
11709
+ * @param tabIds List of tab IDs to move.
11710
+ *
11711
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11806
11712
  */
11807
11713
  export function move(tabId: number, moveProperties: MoveProperties): Promise<Tab>;
11808
- /**
11809
- * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
11810
- * @param tabId The tab to move.
11811
- * @param callback Optional.
11812
- * Parameter tab: Details about the moved tab.
11813
- */
11814
- export function move(tabId: number, moveProperties: MoveProperties, callback: (tab: Tab) => void): void;
11815
- /**
11816
- * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
11817
- * @param tabIds The tabs to move.
11818
- * @return The `move` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the moved tabs.
11819
- */
11820
11714
  export function move(tabIds: number[], moveProperties: MoveProperties): Promise<Tab[]>;
11821
- /**
11822
- * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
11823
- * @param tabIds The tabs to move.
11824
- * @param callback Optional.
11825
- * Parameter tabs: Details about the moved tabs.
11826
- */
11715
+ export function move(tabId: number, moveProperties: MoveProperties, callback: (tab: Tab) => void): void;
11827
11716
  export function move(tabIds: number[], moveProperties: MoveProperties, callback: (tabs: Tab[]) => void): void;
11717
+
11828
11718
  /**
11829
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11830
- * @return The `update` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the updated tab. The `url`, `pendingUrl`, `title` and `favIconUrl` properties are only included on the {@link tabs.Tab} object if the extension has the `tabs` permission or has host permissions for the page..
11719
+ * Modifies the properties of a tab. Properties that are not specified in `updateProperties` are not modified.
11720
+ *
11721
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11722
+ * @param tabId Defaults to the selected tab of the current window.
11831
11723
  */
11832
11724
  export function update(updateProperties: UpdateProperties): Promise<Tab | undefined>;
11833
- /**
11834
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11835
- * @param callback Optional.
11836
- * Optional parameter tab: Details about the updated tab. The `url`, `pendingUrl`, `title` and `favIconUrl` properties are only included on the {@link tabs.Tab} object if the extension has the `tabs` permission or has host permissions for the page..
11837
- */
11725
+ export function update(tabId: number | undefined, updateProperties: UpdateProperties): Promise<Tab | undefined>;
11838
11726
  export function update(updateProperties: UpdateProperties, callback: (tab?: Tab) => void): void;
11727
+ export function update(
11728
+ tabId: number | undefined,
11729
+ updateProperties: UpdateProperties,
11730
+ callback: (tab?: Tab) => void,
11731
+ ): void;
11732
+
11839
11733
  /**
11840
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11841
- * @param tabId Defaults to the selected tab of the current window.
11842
- * @return The `update` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the updated tab. The `url`, `pendingUrl`, `title` and `favIconUrl` properties are only included on the {@link tabs.Tab} object if the extension has the `tabs` permission or has host permissions for the page..
11843
- */
11844
- export function update(tabId: number, updateProperties: UpdateProperties): Promise<Tab | undefined>;
11845
- /**
11846
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11847
- * @param tabId Defaults to the selected tab of the current window.
11848
- * @param callback Optional.
11849
- * Optional parameter tab: Details about the updated tab. The `url`, `pendingUrl`, `title` and `favIconUrl` properties are only included on the {@link tabs.Tab} object if the extension has the `tabs` permission or has host permissions for the page..
11850
- */
11851
- export function update(tabId: number, updateProperties: UpdateProperties, callback: (tab?: Tab) => void): void;
11852
- /**
11853
- * Closes a tab.
11854
- * @param tabId The tab to close.
11855
- * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11734
+ * Closes one or more tabs.
11735
+ *
11736
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11737
+ * @param tabId The tab ID to close.
11738
+ * @param tabIds List of tab IDs to close.
11856
11739
  */
11857
11740
  export function remove(tabId: number): Promise<void>;
11858
- /**
11859
- * Closes a tab.
11860
- * @param tabId The tab to close.
11861
- */
11862
- export function remove(tabId: number, callback: () => void): void;
11863
- /**
11864
- * Closes several tabs.
11865
- * @param tabIds The list of tabs to close.
11866
- * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11867
- */
11868
11741
  export function remove(tabIds: number[]): Promise<void>;
11869
- /**
11870
- * Closes several tabs.
11871
- * @param tabIds The list of tabs to close.
11872
- */
11742
+ export function remove(tabId: number, callback: () => void): void;
11873
11743
  export function remove(tabIds: number[], callback: () => void): void;
11744
+
11874
11745
  /**
11875
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11876
- * @param callback
11877
- * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11878
- */
11879
- export function captureVisibleTab(callback: (dataUrl: string) => void): void;
11880
- /**
11881
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11882
- * @return The `captureVisibleTab` method provides its result via callback or returned as a `Promise` (MV3 only). A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11746
+ * Captures the visible area of the currently active tab in the specified window. In order to call this method, the extension must have either the [<all\_urls>](https://developer.chrome.com/extensions/develop/concepts/declare-permissions) permission or the [activeTab](https://developer.chrome.com/docs/extensions/develop/concepts/activeTab) permission. In addition to sites that extensions can normally access, this method allows extensions to capture sensitive sites that are otherwise restricted, including chrome:-scheme pages, other extensions' pages, and data: URLs. These sensitive sites can only be captured with the activeTab permission. File URLs may be captured only if the extension has been granted file access.
11747
+ *
11748
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11749
+ * @param windowId The target window. Defaults to the current window.
11883
11750
  */
11884
11751
  export function captureVisibleTab(): Promise<string>;
11885
- /**
11886
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11887
- * @param windowId Optional. The target window. Defaults to the current window.
11888
- * @param callback
11889
- * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11890
- */
11891
- export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void;
11892
- /**
11893
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11894
- * @param windowId Optional. The target window. Defaults to the current window.
11895
- * @return The `captureVisibleTab` method provides its result via callback or returned as a `Promise` (MV3 only). A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11896
- */
11897
11752
  export function captureVisibleTab(windowId: number): Promise<string>;
11898
- /**
11899
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11900
- * @param options Optional. Details about the format and quality of an image.
11901
- * @return The `captureVisibleTab` method provides its result via callback or returned as a `Promise` (MV3 only). A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11902
- */
11903
11753
  export function captureVisibleTab(options: extensionTypes.ImageDetails): Promise<string>;
11904
- /**
11905
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11906
- * @param options Optional. Details about the format and quality of an image.
11907
- * @param callback
11908
- * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11909
- */
11754
+ export function captureVisibleTab(windowId: number, options: extensionTypes.ImageDetails): Promise<string>;
11755
+ export function captureVisibleTab(callback: (dataUrl: string) => void): void;
11756
+ export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void;
11910
11757
  export function captureVisibleTab(
11911
11758
  options: extensionTypes.ImageDetails,
11912
11759
  callback: (dataUrl: string) => void,
11913
11760
  ): void;
11914
- /**
11915
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11916
- * @param windowId Optional. The target window. Defaults to the current window.
11917
- * @param options Optional. Details about the format and quality of an image.
11918
- * @return The `captureVisibleTab` method provides its result via callback or returned as a `Promise` (MV3 only). A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11919
- */
11920
- export function captureVisibleTab(
11921
- windowId: number,
11922
- options: extensionTypes.ImageDetails,
11923
- ): Promise<string>;
11924
- /**
11925
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11926
- * @param windowId Optional. The target window. Defaults to the current window.
11927
- * @param options Optional. Details about the format and quality of an image.
11928
- * @param callback
11929
- * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
11930
- */
11931
11761
  export function captureVisibleTab(
11932
11762
  windowId: number,
11933
11763
  options: extensionTypes.ImageDetails,
11934
11764
  callback: (dataUrl: string) => void,
11935
11765
  ): void;
11766
+
11936
11767
  /**
11937
11768
  * Reload a tab.
11938
- * @since Chrome 16
11769
+ *
11770
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11939
11771
  * @param tabId The ID of the tab to reload; defaults to the selected tab of the current window.
11940
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11941
11772
  */
11773
+ export function reload(): Promise<void>;
11942
11774
  export function reload(tabId: number): Promise<void>;
11943
- /**
11944
- * Reload a tab.
11945
- * @since Chrome 16
11946
- * @param tabId The ID of the tab to reload; defaults to the selected tab of the current window.
11947
- */
11948
- export function reload(tabId: number, callback?: () => void): void;
11949
- /**
11950
- * Reload the selected tab of the current window.
11951
- * @since Chrome 16
11952
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11953
- */
11954
11775
  export function reload(reloadProperties: ReloadProperties): Promise<void>;
11955
- /**
11956
- * Reload the selected tab of the current window.
11957
- * @since Chrome 16
11958
- */
11959
- export function reload(reloadProperties: ReloadProperties, callback: () => void): void;
11960
- /**
11961
- * Reload the selected tab of the current window.
11962
- * @since Chrome 16
11963
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11964
- */
11965
11776
  export function reload(tabId: number, reloadProperties: ReloadProperties): Promise<void>;
11966
- /**
11967
- * Reload the selected tab of the current window.
11968
- * @since Chrome 16
11969
- */
11970
- export function reload(tabId: number, reloadProperties: ReloadProperties, callback: () => void): void;
11971
- /**
11972
- * Reload the selected tab of the current window.
11973
- * @since Chrome 16
11974
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11975
- */
11976
- export function reload(): Promise<void>;
11977
- /**
11978
- * Reload the selected tab of the current window.
11979
- * @since Chrome 16
11980
- */
11981
11777
  export function reload(callback: () => void): void;
11778
+ export function reload(tabId: number | undefined, callback: () => void): void;
11779
+ export function reload(reloadProperties: ReloadProperties | undefined, callback: () => void): void;
11780
+ export function reload(
11781
+ tabId: number | undefined,
11782
+ reloadProperties: ReloadProperties | undefined,
11783
+ callback: () => void,
11784
+ ): void;
11785
+
11982
11786
  /**
11983
11787
  * Duplicates a tab.
11984
- * @since Chrome 23
11985
- * @param tabId The ID of the tab which is to be duplicated.
11986
- * @return The `duplicate` method provides its result via callback or returned as a `Promise` (MV3 only).
11788
+ *
11789
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11790
+ * @param tabId The ID of the tab to duplicate.
11987
11791
  */
11988
11792
  export function duplicate(tabId: number): Promise<Tab | undefined>;
11989
- /**
11990
- * Duplicates a tab.
11991
- * @since Chrome 23
11992
- * @param tabId The ID of the tab which is to be duplicated.
11993
- * @param callback Optional.
11994
- * Optional parameter tab: Details about the duplicated tab. The `url`, `pendingUrl`, `title` and `favIconUrl` properties are only included on the {@link tabs.Tab} object if the extension has the `tabs` permission or has host permissions for the page.
11995
- */
11996
11793
  export function duplicate(tabId: number, callback: (tab?: Tab) => void): void;
11794
+
11997
11795
  /**
11998
- * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension.
11999
- * @since Chrome 20
11796
+ * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The {@link runtime.onMessage} event is fired in each content script running in the specified tab for the current extension.
11797
+ *
11798
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
12000
11799
  */
12001
11800
  export function sendMessage<M = any, R = any>(
12002
11801
  tabId: number,
12003
11802
  message: M,
12004
- responseCallback: (response: R) => void,
12005
- ): void;
12006
- /**
12007
- * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension.
12008
- * @since Chrome 41
12009
- * @param responseCallback Optional.
12010
- * Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message.
12011
- */
11803
+ options?: MessageSendOptions,
11804
+ ): Promise<R>;
12012
11805
  export function sendMessage<M = any, R = any>(
12013
11806
  tabId: number,
12014
11807
  message: M,
12015
- options: MessageSendOptions,
12016
- responseCallback: (response: R) => void,
11808
+ /** @since Chrome 99 */
11809
+ callback: (response: R) => void,
12017
11810
  ): void;
12018
- /**
12019
- * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension.
12020
- * @since Chrome 99
12021
- */
12022
- export function sendMessage<M = any, R = any>(tabId: number, message: M): Promise<R>;
12023
- /**
12024
- * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension.
12025
- * @since Chrome 99
12026
- */
12027
11811
  export function sendMessage<M = any, R = any>(
12028
11812
  tabId: number,
12029
11813
  message: M,
12030
- options: MessageSendOptions,
12031
- ): Promise<R>;
11814
+ options: MessageSendOptions | undefined,
11815
+ /** @since Chrome 99 */
11816
+ callback: (response: R) => void,
11817
+ ): void;
11818
+
12032
11819
  /**
12033
- * Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest event is fired in each content script running in the specified tab for the current extension.
12034
- * @deprecated since Chrome 33. Please use runtime.sendMessage.
12035
- * @param responseCallback Optional.
12036
- * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message.
11820
+ * Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The {@link extension.onRequest} event is fired in each content script running in the specified tab for the current extension.
11821
+ *
11822
+ * MV2 only
11823
+ * @deprecated Please use {@link runtime.sendMessage}.
12037
11824
  */
12038
11825
  export function sendRequest<Request = any, Response = any>(
12039
11826
  tabId: number,
12040
11827
  request: Request,
12041
- responseCallback?: (response: Response) => void,
11828
+ ): Promise<Response>;
11829
+ export function sendRequest<Request = any, Response = any>(
11830
+ tabId: number,
11831
+ request: Request,
11832
+ /** @since Chrome 99 */
11833
+ callback?: (response: Response) => void,
12042
11834
  ): void;
12043
- /** Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. */
12044
- export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port;
11835
+
12045
11836
  /**
12046
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12047
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
12048
- * @return The `insertCSS` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11837
+ * Connects to the content script(s) in the specified tab. The {@link runtime.onConnect} event is fired in each content script running in the specified tab for the current extension.
11838
+ * @returns A port that can be used to communicate with the content scripts running in the specified tab. The port's {@link runtime.Port} event is fired if the tab closes or does not exist.
12049
11839
  */
12050
- export function insertCSS(details: extensionTypes.InjectDetails): Promise<void>;
11840
+ export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port;
11841
+
12051
11842
  /**
12052
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12053
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
12054
- * @param callback Optional. Called when all the CSS has been inserted.
11843
+ * Injects CSS into a page. Styles inserted with this method can be removed with {@link scripting.removeCSS}`. For details, see the programmatic injection section of the content scripts doc.
11844
+ *
11845
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11846
+ *
11847
+ * MV2 only
11848
+ * @param tabId The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
11849
+ * @param details Details of the CSS text to insert. Either the code or the file property must be set, but both may not be set at the same time.
11850
+ * @deprecated since Chrome 99. Replaced by {@link scripting.insertCSS} in Manifest V3.
12055
11851
  */
11852
+ export function insertCSS(details: extensionTypes.InjectDetails): Promise<void>;
11853
+ export function insertCSS(tabId: number | undefined, details: extensionTypes.InjectDetails): Promise<void>;
12056
11854
  export function insertCSS(details: extensionTypes.InjectDetails, callback: () => void): void;
12057
- /**
12058
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12059
- * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
12060
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
12061
- * @return The `insertCSS` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12062
- */
12063
- export function insertCSS(tabId: number, details: extensionTypes.InjectDetails): Promise<void>;
12064
- /**
12065
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12066
- * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
12067
- * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.
12068
- * @param callback Optional. Called when all the CSS has been inserted.
12069
- */
11855
+ export function insertCSS(tabId: number | undefined, details: extensionTypes.InjectDetails): Promise<void>;
12070
11856
  export function insertCSS(tabId: number, details: extensionTypes.InjectDetails, callback: () => void): void;
11857
+
12071
11858
  /**
12072
- * Highlights the given tabs.
12073
- * @since Chrome 16
12074
- * @return The `highlight` method provides its result via callback or returned as a `Promise` (MV3 only). Contains details about the window whose tabs were highlighted.
12075
- */
12076
- export function highlight(highlightInfo: HighlightInfo): Promise<chrome.windows.Window>;
12077
- /**
12078
- * Highlights the given tabs.
12079
- * @since Chrome 16
12080
- * @param callback Optional.
12081
- * Parameter window: Contains details about the window whose tabs were highlighted.
12082
- */
12083
- export function highlight(
12084
- highlightInfo: HighlightInfo,
12085
- callback: (window: chrome.windows.Window) => void,
12086
- ): void;
12087
- /**
12088
- * Gets all tabs that have the specified properties, or all tabs if no properties are specified.
12089
- * @since Chrome 16
12090
- */
12091
- export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void;
12092
- /**
12093
- * Gets all tabs that have the specified properties, or all tabs if no properties are specified.
12094
- * @since Chrome 16
12095
- * @return The `query` method provides its result via callback or returned as a `Promise` (MV3 only).
11859
+ * Highlights the given tabs and focuses on the first of group. Will appear to do nothing if the specified tab is currently active.
11860
+ *
11861
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
12096
11862
  */
11863
+ export function highlight(highlightInfo: HighlightInfo): Promise<windows.Window>;
11864
+ export function highlight(highlightInfo: HighlightInfo, callback: (window: windows.Window) => void): void;
11865
+
11866
+ /** Gets all tabs that have the specified properties, or all tabs if no properties are specified. */
12097
11867
  export function query(queryInfo: QueryInfo): Promise<Tab[]>;
11868
+ export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void;
11869
+
12098
11870
  /**
12099
11871
  * Detects the primary language of the content in a tab.
12100
- * @param callback
12101
- * Parameter language: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned.
11872
+ *
11873
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11874
+ * @param tabId The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12102
11875
  */
11876
+ export function detectLanguage(tabId?: number): Promise<string>;
12103
11877
  export function detectLanguage(callback: (language: string) => void): void;
12104
- /**
12105
- * Detects the primary language of the content in a tab.
12106
- * @return The `detectLanguage` method provides its result via callback or returned as a `Promise` (MV3 only). An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned.
12107
- */
12108
- export function detectLanguage(): Promise<string>;
12109
- /**
12110
- * Detects the primary language of the content in a tab.
12111
- * @param tabId Optional. Defaults to the active tab of the current window.
12112
- * @param callback
12113
- * Parameter language: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned.
12114
- */
12115
- export function detectLanguage(tabId: number, callback: (language: string) => void): void;
12116
- /**
12117
- * Detects the primary language of the content in a tab.
12118
- * @param tabId Optional. Defaults to the active tab of the current window.
12119
- * @return The `detectLanguage` method provides its result via callback or returned as a `Promise` (MV3 only). An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned.
12120
- */
12121
- export function detectLanguage(tabId: number): Promise<string>;
11878
+ export function detectLanguage(tabId: number | undefined, callback: (language: string) => void): void;
11879
+
12122
11880
  /**
12123
11881
  * Zooms a specified tab.
12124
- * @since Chrome 42
12125
- * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab.
12126
- * @return The `setZoom` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11882
+ *
11883
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11884
+ * @param tabId The ID of the tab to zoom; defaults to the active tab of the current window.
11885
+ * @param zoomFactor The new zoom factor. A value of `0` sets the tab to its current default zoom factor. Values greater than 0 specify a (possibly non-default) zoom factor for the tab.
12127
11886
  */
12128
11887
  export function setZoom(zoomFactor: number): Promise<void>;
12129
- /**
12130
- * Zooms a specified tab.
12131
- * @since Chrome 42
12132
- * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab.
12133
- * @param callback Optional. Called after the zoom factor has been changed.
12134
- */
11888
+ export function setZoom(tabId: number | undefined, zoomFactor: number): Promise<void>;
12135
11889
  export function setZoom(zoomFactor: number, callback: () => void): void;
12136
- /**
12137
- * Zooms a specified tab.
12138
- * @since Chrome 42
12139
- * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window.
12140
- * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab.
12141
- * @return The `setZoom` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12142
- */
12143
- export function setZoom(tabId: number, zoomFactor: number): Promise<void>;
12144
- /**
12145
- * Zooms a specified tab.
12146
- * @since Chrome 42
12147
- * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window.
12148
- * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab.
12149
- * @param callback Optional. Called after the zoom factor has been changed.
12150
- */
12151
- export function setZoom(tabId: number, zoomFactor: number, callback: () => void): void;
11890
+ export function setZoom(tabId: number | undefined, zoomFactor: number, callback: () => void): void;
11891
+
12152
11892
  /**
12153
11893
  * Gets the current zoom factor of a specified tab.
12154
- * @since Chrome 42
12155
- * @param callback Called with the tab's current zoom factor after it has been fetched.
12156
- * Parameter zoomFactor: The tab's current zoom factor.
11894
+ *
11895
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11896
+ * @param tabId The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12157
11897
  */
11898
+ export function getZoom(tabId?: number): Promise<number>;
12158
11899
  export function getZoom(callback: (zoomFactor: number) => void): void;
12159
- /**
12160
- * Gets the current zoom factor of a specified tab.
12161
- * @since Chrome 42
12162
- * @return The `getZoom` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom factor.
12163
- */
12164
- export function getZoom(): Promise<number>;
12165
- /**
12166
- * Gets the current zoom factor of a specified tab.
12167
- * @since Chrome 42
12168
- * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12169
- * @param callback Called with the tab's current zoom factor after it has been fetched.
12170
- * Parameter zoomFactor: The tab's current zoom factor.
12171
- */
12172
- export function getZoom(tabId: number, callback: (zoomFactor: number) => void): void;
12173
- /**
12174
- * Gets the current zoom factor of a specified tab.
12175
- * @since Chrome 42
12176
- * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12177
- * @return The `getZoom` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom factor.
12178
- */
12179
- export function getZoom(tabId: number): Promise<number>;
11900
+ export function getZoom(tabId: number | undefined, callback: (zoomFactor: number) => void): void;
11901
+
12180
11902
  /**
12181
11903
  * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
12182
- * @since Chrome 42
11904
+ *
11905
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11906
+ * @param tabId The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12183
11907
  * @param zoomSettings Defines how zoom changes are handled and at what scope.
12184
- * @return The `setZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12185
11908
  */
12186
11909
  export function setZoomSettings(zoomSettings: ZoomSettings): Promise<void>;
12187
- /**
12188
- * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
12189
- * @since Chrome 42
12190
- * @param zoomSettings Defines how zoom changes are handled and at what scope.
12191
- * @param callback Optional. Called after the zoom settings have been changed.
12192
- */
11910
+ export function setZoomSettings(tabId: number | undefined, zoomSettings: ZoomSettings): Promise<void>;
12193
11911
  export function setZoomSettings(zoomSettings: ZoomSettings, callback: () => void): void;
12194
- /**
12195
- * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
12196
- * @since Chrome 42
12197
- * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12198
- * @param zoomSettings Defines how zoom changes are handled and at what scope.
12199
- * @return The `setZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12200
- */
12201
- export function setZoomSettings(tabId: number, zoomSettings: ZoomSettings): Promise<void>;
12202
- /**
12203
- * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
12204
- * @since Chrome 42
12205
- * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12206
- * @param zoomSettings Defines how zoom changes are handled and at what scope.
12207
- * @param callback Optional. Called after the zoom settings have been changed.
12208
- */
12209
- export function setZoomSettings(tabId: number, zoomSettings: ZoomSettings, callback: () => void): void;
11912
+ export function setZoomSettings(
11913
+ tabId: number | undefined,
11914
+ zoomSettings: ZoomSettings,
11915
+ callback: () => void,
11916
+ ): void;
11917
+
12210
11918
  /**
12211
11919
  * Gets the current zoom settings of a specified tab.
12212
- * @since Chrome 42
12213
- * @param callback Called with the tab's current zoom settings.
12214
- * Parameter zoomSettings: The tab's current zoom settings.
11920
+ *
11921
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11922
+ * @param tabId The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12215
11923
  */
11924
+ export function getZoomSettings(tabId?: number): Promise<ZoomSettings>;
12216
11925
  export function getZoomSettings(callback: (zoomSettings: ZoomSettings) => void): void;
12217
- /**
12218
- * Gets the current zoom settings of a specified tab.
12219
- * @since Chrome 42
12220
- * @return The `getZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom settings.
12221
- */
12222
- export function getZoomSettings(): Promise<ZoomSettings>;
12223
- /**
12224
- * Gets the current zoom settings of a specified tab.
12225
- * @since Chrome 42
12226
- * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12227
- * @param callback Called with the tab's current zoom settings.
12228
- * Parameter zoomSettings: The tab's current zoom settings.
12229
- */
12230
- export function getZoomSettings(tabId: number, callback: (zoomSettings: ZoomSettings) => void): void;
12231
- /**
12232
- * Gets the current zoom settings of a specified tab.
12233
- * @since Chrome 42
12234
- * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12235
- * @return The `getZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom settings.
12236
- */
12237
- export function getZoomSettings(tabId: number): Promise<ZoomSettings>;
12238
- /**
12239
- * Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
12240
- * @since Chrome 54
12241
- * @param tabId Optional. The ID of the tab to be discarded. If specified, the tab will be discarded unless it's active or already discarded. If omitted, the browser will discard the least important tab. This can fail if no discardable tabs exist.
12242
- * @return The `discard` method provides its result via callback or returned as a `Promise` (MV3 only).
12243
- */
12244
- export function discard(tabId?: number): Promise<Tab>;
11926
+ export function getZoomSettings(
11927
+ tabId: number | undefined,
11928
+ callback: (zoomSettings: ZoomSettings) => void,
11929
+ ): void;
11930
+
12245
11931
  /**
12246
11932
  * Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
11933
+ *
11934
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11935
+ * @param tabId The ID of the tab to be discarded. If specified, the tab is discarded unless it is active or already discarded. If omitted, the browser discards the least important tab. This can fail if no discardable tabs exist..
12247
11936
  * @since Chrome 54
12248
- * @param tabId Optional. The ID of the tab to be discarded. If specified, the tab will be discarded unless it's active or already discarded. If omitted, the browser will discard the least important tab. This can fail if no discardable tabs exist.
12249
- * @param callback Called after the operation is completed.
12250
11937
  */
12251
- export function discard(callback: (tab: Tab) => void): void;
12252
- export function discard(tabId: number, callback: (tab: Tab) => void): void;
12253
- /**
12254
- * Go forward to the next page, if one is available.
12255
- * @since Chrome 72
12256
- * @return The `goForward` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12257
- */
12258
- export function goForward(): Promise<void>;
11938
+ export function discard(tabId?: number): Promise<Tab | undefined>;
11939
+ export function discard(callback: (tab?: Tab) => void): void;
11940
+ export function discard(tabId: number | undefined, callback: (tab?: Tab) => void): void;
11941
+
12259
11942
  /**
12260
11943
  * Go forward to the next page, if one is available.
11944
+ *
11945
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11946
+ * @param tabId The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12261
11947
  * @since Chrome 72
12262
- * @param callback Optional. Called after the operation is completed.
12263
11948
  */
11949
+ export function goForward(tabId?: number): Promise<void>;
12264
11950
  export function goForward(callback: () => void): void;
12265
- /**
12266
- * Go forward to the next page, if one is available.
12267
- * @since Chrome 72
12268
- * @param tabId Optional. The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12269
- * @return The `goForward` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12270
- */
12271
- export function goForward(tabId: number): Promise<void>;
12272
- /**
12273
- * Go forward to the next page, if one is available.
12274
- * @since Chrome 72
12275
- * @param tabId Optional. The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12276
- * @param callback Optional. Called after the operation is completed.
12277
- */
12278
- export function goForward(tabId: number, callback: () => void): void;
12279
- /**
12280
- * Go back to the previous page, if one is available.
12281
- * @since Chrome 72
12282
- * @return The `goBack` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12283
- */
12284
- export function goBack(): Promise<void>;
11951
+ export function goForward(tabId: number | undefined, callback: () => void): void;
11952
+
12285
11953
  /**
12286
11954
  * Go back to the previous page, if one is available.
11955
+ *
11956
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11957
+ * @param tabId The ID of the tab to navigate back; defaults to the selected tab of the current window.
12287
11958
  * @since Chrome 72
12288
- * @param callback Optional. Called after the operation is completed.
12289
11959
  */
11960
+ export function goBack(tabId?: number): Promise<void>;
12290
11961
  export function goBack(callback: () => void): void;
12291
- /**
12292
- * Go back to the previous page, if one is available.
12293
- * @since Chrome 72
12294
- * @param tabId Optional. The ID of the tab to navigate back; defaults to the selected tab of the current window.
12295
- * @return The `goBack` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12296
- */
12297
- export function goBack(tabId: number): Promise<void>;
12298
- /**
12299
- * Go back to the previous page, if one is available.
12300
- * @since Chrome 72
12301
- * @param tabId Optional. The ID of the tab to navigate back; defaults to the selected tab of the current window.
12302
- * @param callback Optional. Called after the operation is completed.
12303
- */
12304
- export function goBack(tabId: number, callback: () => void): void;
12305
- /**
12306
- * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
12307
- * @since Chrome 88
12308
- * @param options Configurations object
12309
- * @return The `group` method provides its result via callback or returned as a `Promise` (MV3 only).
12310
- */
12311
- export function group(options: GroupOptions): Promise<number>;
11962
+ export function goBack(tabId: number | undefined, callback: () => void): void;
11963
+
12312
11964
  /**
12313
11965
  * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
11966
+ *
11967
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
12314
11968
  * @since Chrome 88
12315
- * @param options Configurations object
12316
- * @return The `group` method provides its result via callback or returned as a `Promise` (MV3 only).
12317
11969
  */
12318
11970
  export function group(options: GroupOptions): Promise<number>;
12319
- /**
12320
- * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
12321
- * @since Chrome 88
12322
- * @param options Configurations object
12323
- * @param callback Optional.
12324
- */
12325
11971
  export function group(options: GroupOptions, callback: (groupId: number) => void): void;
11972
+
12326
11973
  /**
12327
11974
  * Removes one or more tabs from their respective groups. If any groups become empty, they are deleted
11975
+ *
11976
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11977
+ * @param tabIds The tab ID or list of tab IDs to remove from their respective groups.
12328
11978
  * @since Chrome 88
12329
- * @param tabIds The tabs to ungroup.
12330
- * @return The `ungroup` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12331
- */
12332
- export function ungroup(tabIds: number | number[]): Promise<void>;
12333
- /**
12334
- * Removes one or more tabs from their respective groups. If any groups become empty, they are deleted
12335
- * @since Chrome 88
12336
- * @param tabIds The tabs to ungroup.
12337
- * @param callback Optional. Called after the operation is completed.
12338
- */
12339
- export function ungroup(tabIds: number | number[], callback: () => void): void;
12340
- /**
12341
- * Fired when the highlighted or selected tabs in a window changes.
12342
- * @since Chrome 18
12343
11979
  */
12344
- export var onHighlighted: TabHighlightedEvent;
11980
+ export function ungroup(tabIds: number | [number, ...number[]]): Promise<void>;
11981
+ export function ungroup(tabIds: number | [number, ...number[]], callback: () => void): void;
11982
+
11983
+ /** Fired when the highlighted or selected tabs in a window changes */
11984
+ export const onHighlighted: events.Event<
11985
+ (highlightInfo: OnHighlightedInfo) => void
11986
+ >;
11987
+
12345
11988
  /** Fired when a tab is closed. */
12346
- export var onRemoved: TabRemovedEvent;
11989
+ export const onRemoved: events.Event<
11990
+ (tabId: number, removeInfo: OnRemovedInfo) => void
11991
+ >;
11992
+
12347
11993
  /** Fired when a tab is updated. */
12348
- export var onUpdated: TabUpdatedEvent;
11994
+ export const onUpdated: events.Event<
11995
+ (tabId: number, changeInfo: OnUpdatedInfo, tab: Tab) => void
11996
+ >;
11997
+
12349
11998
  /** Fired when a tab is attached to a window, for example because it was moved between windows. */
12350
- export var onAttached: TabAttachedEvent;
12351
- /**
12352
- * Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see tabs.onDetached.
12353
- */
12354
- export var onMoved: TabMovedEvent;
12355
- /** Fired when a tab is detached from a window, for example because it is being moved between windows. */
12356
- export var onDetached: TabDetachedEvent;
12357
- /** Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set. */
12358
- export var onCreated: TabCreatedEvent;
12359
- /**
12360
- * Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
12361
- * @since Chrome 18
12362
- */
12363
- export var onActivated: TabActivatedEvent;
12364
- /**
12365
- * Fired when a tab is replaced with another tab due to prerendering or instant.
12366
- * @since Chrome 26
12367
- */
12368
- export var onReplaced: TabReplacedEvent;
11999
+ export const onAttached: events.Event<
12000
+ (tabId: number, attachInfo: OnAttachedInfo) => void
12001
+ >;
12002
+
12003
+ /** Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response to the manually-moved tab. This event is not fired when a tab is moved between windows; for details, see {@link tabs.onDetached}. */
12004
+ export const onMoved: events.Event<
12005
+ (tabId: number, moveInfo: OnMovedInfo) => void
12006
+ >;
12007
+
12008
+ /** Fired when a tab is detached from a window; for example, because it was moved between windows. */
12009
+ export const onDetached: events.Event<
12010
+ (tabId: number, detachInfo: OnDetachedInfo) => void
12011
+ >;
12012
+
12013
+ /** Fired when a tab is created. Note that the tab's URL and tab group membership may not be set at the time this event is fired, but you can listen to onUpdated events so as to be notified when a URL is set or the tab is added to a tab group. */
12014
+ export const onCreated: events.Event<(tab: Tab) => void>;
12015
+
12016
+ /** Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events so as to be notified when a URL is set */
12017
+ export const onActivated: events.Event<
12018
+ (activeInfo: OnActivatedInfo) => void
12019
+ >;
12020
+
12021
+ /** Fired when a tab is replaced with another tab due to prerendering or instant */
12022
+ export const onReplaced: events.Event<
12023
+ (addedTabId: number, removedTabId: number) => void
12024
+ >;
12025
+
12369
12026
  /**
12370
- * @deprecated since Chrome 33. Please use tabs.onActivated.
12371
12027
  * Fires when the selected tab in a window changes.
12028
+ *
12029
+ * MV2 only
12030
+ * @deprecated Please use {@link tabs.onActivated}.
12372
12031
  */
12373
- export var onSelectionChanged: TabSelectedEvent;
12032
+ export const onSelectionChanged: events.Event<
12033
+ (tabId: number, selectInfo: OnSelectionChangedInfo) => void
12034
+ >;
12035
+
12374
12036
  /**
12375
- * @deprecated since Chrome 33. Please use tabs.onActivated.
12376
- * Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to tabs.onUpdated events to be notified when a URL is set.
12037
+ * Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to {@link tabs.onUpdated} events so as to be notified when a URL is set.
12038
+ *
12039
+ * MV2 only
12040
+ * @deprecated Please use {@link tabs.onActivated}.
12377
12041
  */
12378
- export var onActiveChanged: TabSelectedEvent;
12042
+ export const onActiveChanged: events.Event<
12043
+ (tabId: number, selectInfo: OnActiveChangedInfo) => void
12044
+ >;
12045
+
12379
12046
  /**
12380
- * @deprecated since Chrome 33. Please use tabs.onHighlighted.
12381
12047
  * Fired when the highlighted or selected tabs in a window changes.
12048
+ *
12049
+ * MV2 only
12050
+ * @deprecated Please use {@link tabs.onHighlighted}.
12382
12051
  */
12383
- export var onHighlightChanged: TabHighlightedEvent;
12384
- /**
12385
- * Fired when a tab is zoomed.
12386
- * @since Chrome 38
12387
- */
12388
- export var onZoomChange: TabZoomChangeEvent;
12052
+ export const onHighlightChanged: events.Event<
12053
+ (selectInfo: OnHighlightChangedInfo) => void
12054
+ >;
12389
12055
 
12390
- /**
12391
- * An ID which represents the absence of a browser tab.
12392
- * @since Chrome 46
12393
- */
12394
- export var TAB_ID_NONE: -1;
12056
+ /** Fired when a tab is zoomed */
12057
+ export const onZoomChange: events.Event<
12058
+ (ZoomChangeInfo: OnZoomChangeInfo) => void
12059
+ >;
12395
12060
  }
12396
12061
 
12397
12062
  ////////////////////