@types/chrome 0.0.330 → 0.0.332

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 +493 -821
  3. chrome/package.json +2 -2
chrome/index.d.ts CHANGED
@@ -8939,11 +8939,13 @@ declare namespace chrome {
8939
8939
  * Use the `chrome.runtime` API to retrieve the service worker, return details about the manifest, and listen for and respond to events in the extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.
8940
8940
  */
8941
8941
  export namespace runtime {
8942
- /** Populated with an error message if calling an API function fails; otherwise undefined. This is only defined within the scope of that function's callback. If an error is produced, but `runtime.lastError` is not accessed within the callback, a message is logged to the console listing the API function that produced the error. API functions that return promises do not set this property. */
8943
- export const lastError: {
8942
+ export interface LastError {
8944
8943
  /** Details about the error which occurred. */
8945
8944
  message?: string;
8946
- } | undefined;
8945
+ }
8946
+
8947
+ /** Populated with an error message if calling an API function fails; otherwise undefined. This is only defined within the scope of that function's callback. If an error is produced, but `runtime.lastError` is not accessed within the callback, a message is logged to the console listing the API function that produced the error. API functions that return promises do not set this property. */
8948
+ export const lastError: LastError | undefined;
8947
8949
 
8948
8950
  /** The ID of the extension/app. */
8949
8951
  export const id: string;
@@ -9171,6 +9173,11 @@ declare namespace chrome {
9171
9173
  name: string;
9172
9174
  }
9173
9175
 
9176
+ export interface UpdateAvailableDetails {
9177
+ /** The version number of the available update. */
9178
+ version: string;
9179
+ }
9180
+
9174
9181
  export interface UpdateCheckDetails {
9175
9182
  /** The version of the available update. */
9176
9183
  version: string;
@@ -9650,7 +9657,7 @@ declare namespace chrome {
9650
9657
  */
9651
9658
  export function requestUpdateCheck(): Promise<RequestUpdateCheckResult>;
9652
9659
  export function requestUpdateCheck(
9653
- callback: (status: `${RequestUpdateCheckStatus}`, details?: { version: string }) => void,
9660
+ callback: (status: `${RequestUpdateCheckStatus}`, details?: UpdateCheckDetails) => void,
9654
9661
  ): void;
9655
9662
 
9656
9663
  /** Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op. */
@@ -9769,7 +9776,7 @@ declare namespace chrome {
9769
9776
  export const onRestartRequired: events.Event<(reason: `${OnRestartRequiredReason}`) => void>;
9770
9777
 
9771
9778
  /** Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call chrome.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call chrome.runtime.reload() manually in response to this event the update will not get installed until the next time Chrome itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if chrome.runtime.reload() is called in response to this event. */
9772
- export const onUpdateAvailable: events.Event<(details: { version: string }) => void>;
9779
+ export const onUpdateAvailable: events.Event<(details: UpdateAvailableDetails) => void>;
9773
9780
 
9774
9781
  /**
9775
9782
  * Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required.
@@ -11198,67 +11205,54 @@ declare namespace chrome {
11198
11205
  */
11199
11206
  export namespace tabs {
11200
11207
  /**
11201
- * Tab muted state and the reason for the last state change.
11208
+ * The tab's muted state and the reason for the last state change.
11202
11209
  * @since Chrome 46
11203
11210
  */
11204
11211
  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. */
11212
+ /** 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
11213
  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
- */
11214
+ /* The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed. */
11215
+ reason?: `${MutedInfoReason}` | undefined;
11216
+ /** 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
11217
  extensionId?: string | undefined;
11220
11218
  }
11221
11219
 
11220
+ /**
11221
+ * An event that caused a muted state change.
11222
+ * @since Chrome 46
11223
+ */
11224
+ export enum MutedInfoReason {
11225
+ /** A user input action set the muted state. */
11226
+ USER = "user",
11227
+ /** Tab capture was started, forcing a muted state change. */
11228
+ CAPTURE = "capture",
11229
+ /** An extension set the muted state. */
11230
+ EXTENSION = "extension",
11231
+ }
11232
+
11222
11233
  export interface Tab {
11223
- /**
11224
- * Optional.
11225
- * Either loading or complete.
11226
- */
11227
- status?: string | undefined;
11234
+ /** The tab's loading status. */
11235
+ status?: `${TabStatus}` | undefined;
11228
11236
  /** The zero-based index of the tab within its window. */
11229
11237
  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
- */
11238
+ /** The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists. */
11235
11239
  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. */
11240
+ /** 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
11241
  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}. */
11242
+ /** 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
11243
  url?: string | undefined;
11240
11244
  /**
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.
11245
+ * 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
11246
  * @since Chrome 79
11244
11247
  */
11245
11248
  pendingUrl?: string | undefined;
11246
- /**
11247
- * Whether the tab is pinned.
11248
- * @since Chrome 9
11249
- */
11249
+ /** Whether the tab is pinned. */
11250
11250
  pinned: boolean;
11251
- /**
11252
- * Whether the tab is highlighted.
11253
- * @since Chrome 16
11254
- */
11251
+ /** Whether the tab is highlighted. */
11255
11252
  highlighted: boolean;
11256
- /** The ID of the window the tab is contained within. */
11253
+ /** The ID of the window that contains the tab. */
11257
11254
  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
- */
11255
+ /** Whether the tab is active in its window. Does not necessarily mean the window is focused. */
11262
11256
  active: boolean;
11263
11257
  /** 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
11258
  favIconUrl?: string | undefined;
@@ -11267,26 +11261,22 @@ declare namespace chrome {
11267
11261
  * @since Chrome 132
11268
11262
  */
11269
11263
  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
- */
11264
+ /** 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
11265
  id?: number | undefined;
11275
11266
  /** Whether the tab is in an incognito window. */
11276
11267
  incognito: boolean;
11277
11268
  /**
11278
11269
  * Whether the tab is selected.
11279
- * @deprecated since Chrome 33. Please use tabs.Tab.highlighted.
11270
+ * @deprecated since Chrome 33. Please use {@link Tab.highlighted}.
11280
11271
  */
11281
11272
  selected: boolean;
11282
11273
  /**
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.
11274
+ * 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
11275
  * @since Chrome 45
11286
11276
  */
11287
11277
  audible?: boolean | undefined;
11288
11278
  /**
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.
11279
+ * 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
11280
  * @since Chrome 54
11291
11281
  */
11292
11282
  discarded: boolean;
@@ -11296,25 +11286,15 @@ declare namespace chrome {
11296
11286
  */
11297
11287
  autoDiscardable: boolean;
11298
11288
  /**
11299
- * Optional.
11300
- * Current tab muted state and the reason for the last state change.
11289
+ * The tab's muted state and the reason for the last state change.
11301
11290
  * @since Chrome 46
11302
11291
  */
11303
11292
  mutedInfo?: MutedInfo | undefined;
11304
- /**
11305
- * Optional. The width of the tab in pixels.
11306
- * @since Chrome 31
11307
- */
11293
+ /** The width of the tab in pixels. */
11308
11294
  width?: number | undefined;
11309
- /**
11310
- * Optional. The height of the tab in pixels.
11311
- * @since Chrome 31
11312
- */
11295
+ /** The height of the tab in pixels. */
11313
11296
  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
- */
11297
+ /** The session ID used to uniquely identify a tab obtained from the {@link sessions} API. */
11318
11298
  sessionId?: string | undefined;
11319
11299
  /**
11320
11300
  * The ID of the group that the tab belongs to.
@@ -11328,203 +11308,201 @@ declare namespace chrome {
11328
11308
  lastAccessed?: number | undefined;
11329
11309
  }
11330
11310
 
11331
- /**
11332
- * Defines how zoom changes in a tab are handled and at what scope.
11333
- * @since Chrome 38
11334
- */
11311
+ /** The tab's loading status. */
11312
+ export enum TabStatus {
11313
+ UNLOADED = "unloaded",
11314
+ LOADING = "loading",
11315
+ COMPLETE = "complete",
11316
+ }
11317
+
11318
+ /** The type of window. */
11319
+ export enum WindowType {
11320
+ NORMAL = "normal",
11321
+ POPUP = "popup",
11322
+ PANEL = "panel",
11323
+ APP = "app",
11324
+ DEVTOOLS = "devtools",
11325
+ }
11326
+
11327
+ /** Defines how zoom changes in a tab are handled and at what scope. */
11335
11328
  export interface ZoomSettings {
11329
+ /** Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to `automatic`. */
11330
+ mode?: `${ZoomSettingsMode}` | undefined;
11331
+ /** 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. */
11332
+ scope?: `${ZoomSettingsScope}` | undefined;
11336
11333
  /**
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.
11334
+ * Used to return the default zoom level for the current tab in calls to {@link tabs.getZoomSettings}.
11354
11335
  * @since Chrome 43
11355
11336
  */
11356
11337
  defaultZoomFactor?: number | undefined;
11357
11338
  }
11358
11339
 
11340
+ /**
11341
+ * Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to `automatic`.
11342
+ * @since Chrome 44
11343
+ */
11344
+ export enum ZoomSettingsMode {
11345
+ /** Zoom changes are handled automatically by the browser. */
11346
+ AUTOMATIC = "automatic",
11347
+ /** 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`. */
11348
+ MANUAL = "manual",
11349
+ /** Disables all zooming in the tab. The tab reverts to the default zoom level, and all attempted zoom changes are ignored. */
11350
+ DISABLED = "disabled",
11351
+ }
11352
+
11353
+ /**
11354
+ * 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.
11355
+ * @since Chrome 44
11356
+ */
11357
+ export enum ZoomSettingsScope {
11358
+ /** 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. */
11359
+ PER_ORIGIN = "per-origin",
11360
+ /** 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. */
11361
+ PER_TAB = "per-tab",
11362
+ }
11363
+
11364
+ /**
11365
+ * The maximum number of times that {@link captureVisibleTab} can be called per second. {@link captureVisibleTab} is expensive and should not be called too often.
11366
+ * @since Chrome 92
11367
+ */
11368
+ export const MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND = 2;
11369
+
11370
+ /**
11371
+ * An ID that represents the absence of a browser tab.
11372
+ * @since Chrome 46
11373
+ */
11374
+ export const TAB_ID_NONE = -1;
11375
+
11376
+ /**
11377
+ * An index that represents the absence of a tab index in a tab_strip.
11378
+ * @since Chrome 123
11379
+ */
11380
+ export const TAB_INDEX_NONE = -1;
11381
+
11359
11382
  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. */
11383
+ /** 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
11384
  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
- */
11385
+ /** 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
11386
  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
- */
11387
+ /** 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
11388
  url?: string | undefined;
11373
- /**
11374
- * Optional. Whether the tab should be pinned. Defaults to false
11375
- * @since Chrome 9
11376
- */
11389
+ /** Whether the tab should be pinned. Defaults to `false` */
11377
11390
  pinned?: boolean | undefined;
11378
- /** Optional. The window to create the new tab in. Defaults to the current window. */
11391
+ /** The window in which to create the new tab. Defaults to the current window. */
11379
11392
  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
- */
11393
+ /** 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
11394
  active?: boolean | undefined;
11386
11395
  /**
11387
- * Optional. Whether the tab should become the selected tab in the window. Defaults to true
11388
- * @deprecated since Chrome 33. Please use active.
11396
+ * Whether the tab should become the selected tab in the window. Defaults to `true`
11397
+ * @deprecated since Chrome 33. Please use {@link CreateProperties.active active}.
11389
11398
  */
11390
11399
  selected?: boolean | undefined;
11391
11400
  }
11392
11401
 
11393
11402
  export interface MoveProperties {
11394
- /** The position to move the window to. -1 will place the tab at the end of the window. */
11403
+ /** The position to move the window to. Use `-1` to place the tab at the end of the window. */
11395
11404
  index: number;
11396
- /** Optional. Defaults to the window the tab is currently in. */
11405
+ /** Defaults to the window the tab is currently in. */
11397
11406
  windowId?: number | undefined;
11398
11407
  }
11399
11408
 
11400
11409
  export interface UpdateProperties {
11401
- /**
11402
- * Optional. Whether the tab should be pinned.
11403
- * @since Chrome 9
11404
- */
11410
+ /** Whether the tab should be pinned. */
11405
11411
  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
- */
11412
+ /** The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab. */
11410
11413
  openerTabId?: number | undefined;
11411
- /** Optional. A URL to navigate the tab to. */
11414
+ /** A URL to navigate the tab to. JavaScript URLs are not supported; use {@link scripting.executeScript} instead. */
11412
11415
  url?: string | undefined;
11413
- /**
11414
- * Optional. Adds or removes the tab from the current selection.
11415
- * @since Chrome 16
11416
- */
11416
+ /** Adds or removes the tab from the current selection. */
11417
11417
  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
- */
11418
+ /** Whether the tab should be active. Does not affect whether the window is focused (see {@link windows.update}).*/
11422
11419
  active?: boolean | undefined;
11423
11420
  /**
11424
- * Optional. Whether the tab should be selected.
11425
- * @deprecated since Chrome 33. Please use highlighted.
11421
+ * Whether the tab should be selected.
11422
+ * @deprecated since Chrome 33. Please use {@link highlighted}.
11426
11423
  */
11427
11424
  selected?: boolean | undefined;
11428
11425
  /**
11429
- * Optional. Whether the tab should be muted.
11426
+ * Whether the tab should be muted.
11430
11427
  * @since Chrome 45
11431
11428
  */
11432
11429
  muted?: boolean | undefined;
11433
11430
  /**
11434
- * Optional. Whether the tab should be discarded automatically by the browser when resources are low.
11431
+ * Whether the tab should be discarded automatically by the browser when resources are low.
11435
11432
  * @since Chrome 54
11436
11433
  */
11437
11434
  autoDiscardable?: boolean | undefined;
11438
11435
  }
11439
11436
 
11440
11437
  export interface ReloadProperties {
11441
- /** Optional. Whether using any local cache. Default is false. */
11438
+ /** Whether to bypass local caching. Defaults to `false`. */
11442
11439
  bypassCache?: boolean | undefined;
11443
11440
  }
11444
11441
 
11445
11442
  export interface ConnectInfo {
11446
- /** Optional. Will be passed into onConnect for content scripts that are listening for the connection event. */
11443
+ /** Is passed into onConnect for content scripts that are listening for the connection event. */
11447
11444
  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
- */
11445
+ /** Open a port to a specific frame identified by `frameId` instead of all frames in the tab. */
11452
11446
  frameId?: number | undefined;
11453
11447
  /**
11454
- * Optional. Open a port to a specific document identified by documentId instead of all frames in the tab.
11448
+ * Open a port to a specific document identified by `documentId` instead of all frames in the tab.
11455
11449
  * @since Chrome 106
11456
11450
  */
11457
11451
  documentId?: string;
11458
11452
  }
11459
11453
 
11460
11454
  export interface MessageSendOptions {
11461
- /** Optional. Send a message to a specific frame identified by frameId instead of all frames in the tab. */
11455
+ /** Send a message to a specific frame identified by `frameId` instead of all frames in the tab. */
11462
11456
  frameId?: number | undefined;
11463
11457
  /**
11464
- * Optional. Send a message to a specific document identified by documentId instead of all frames in the tab.
11458
+ * Send a message to a specific document identified by `documentId` instead of all frames in the tab.
11465
11459
  * @since Chrome 106
11466
11460
  */
11467
11461
  documentId?: string;
11468
11462
  }
11469
11463
 
11470
11464
  export interface GroupOptions {
11471
- /** Optional. Configurations for creating a group. Cannot be used if groupId is already specified. */
11465
+ /** Configurations for creating a group. Cannot be used if groupId is already specified. */
11472
11466
  createProperties?: {
11473
- /** Optional. The window of the new group. Defaults to the current window. */
11467
+ /** The window of the new group. Defaults to the current window. */
11474
11468
  windowId?: number | undefined;
11475
11469
  } | undefined;
11476
- /** Optional. The ID of the group to add the tabs to. If not specified, a new group will be created. */
11470
+ /** The ID of the group to add the tabs to. If not specified, a new group will be created. */
11477
11471
  groupId?: number | undefined;
11478
- /** TOptional. he tab ID or list of tab IDs to add to the specified group. */
11479
- tabIds?: number | number[] | undefined;
11472
+ /** The tab ID or list of tab IDs to add to the specified group. */
11473
+ tabIds?: number | [number, ...number[]] | undefined;
11480
11474
  }
11481
11475
 
11482
11476
  export interface HighlightInfo {
11483
11477
  /** One or more tab indices to highlight. */
11484
11478
  tabs: number | number[];
11485
- /** Optional. The window that contains the tabs. */
11479
+ /** The window that contains the tabs. */
11486
11480
  windowId?: number | undefined;
11487
11481
  }
11488
11482
 
11489
11483
  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
- */
11484
+ /** The tab loading status. */
11485
+ status?: `${TabStatus}` | undefined;
11486
+ /** Whether the tabs are in the last focused window. */
11499
11487
  lastFocusedWindow?: boolean | undefined;
11500
- /** Optional. The ID of the parent window, or windows.WINDOW_ID_CURRENT for the current window. */
11488
+ /** The ID of the parent window, or {@link windows.WINDOW_ID_CURRENT} for the current window. */
11501
11489
  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. */
11490
+ /** The type of window the tabs are in. */
11491
+ windowType?: `${WindowType}` | undefined;
11492
+ /** Whether the tabs are active in their windows. */
11508
11493
  active?: boolean | undefined;
11509
- /**
11510
- * Optional. The position of the tabs within their windows.
11511
- * @since Chrome 18
11512
- */
11494
+ /** The position of the tabs within their windows. */
11513
11495
  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. */
11496
+ /** 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
11497
  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. */
11498
+ /** 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
11499
  url?: string | string[] | undefined;
11518
- /**
11519
- * Optional. Whether the tabs are in the current window.
11520
- * @since Chrome 19
11521
- */
11500
+ /** Whether the tabs are in the current window. */
11522
11501
  currentWindow?: boolean | undefined;
11523
- /** Optional. Whether the tabs are highlighted. */
11502
+ /** Whether the tabs are highlighted. */
11524
11503
  highlighted?: boolean | undefined;
11525
11504
  /**
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.
11505
+ * 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
11506
  * @since Chrome 54
11529
11507
  */
11530
11508
  discarded?: boolean | undefined;
@@ -11532,866 +11510,560 @@ declare namespace chrome {
11532
11510
  * 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
11511
  * @since Chrome 132
11534
11512
  */
11535
- frozen?: boolean;
11513
+ frozen?: boolean | undefined;
11536
11514
  /**
11537
- * Optional.
11538
11515
  * Whether the tabs can be discarded automatically by the browser when resources are low.
11539
11516
  * @since Chrome 54
11540
11517
  */
11541
11518
  autoDiscardable?: boolean | undefined;
11542
- /** Optional. Whether the tabs are pinned. */
11519
+ /** Whether the tabs are pinned. */
11543
11520
  pinned?: boolean | undefined;
11544
11521
  /**
11545
- * Optional. Whether the tabs are audible.
11522
+ * Whether the tabs are audible.
11546
11523
  * @since Chrome 45
11547
11524
  */
11548
11525
  audible?: boolean | undefined;
11549
11526
  /**
11550
- * Optional. Whether the tabs are muted.
11527
+ * Whether the tabs are muted.
11551
11528
  * @since Chrome 45
11552
11529
  */
11553
11530
  muted?: boolean | undefined;
11554
11531
  /**
11555
- * Optional. The ID of the group that the tabs are in, or chrome.tabGroups.TAB_GROUP_ID_NONE for ungrouped tabs.
11532
+ * The ID of the group that the tabs are in, or {@link chrome.tabGroups.TAB_GROUP_ID_NONE} for ungrouped tabs.
11556
11533
  * @since Chrome 88
11557
11534
  */
11558
11535
  groupId?: number | undefined;
11559
11536
  }
11560
11537
 
11561
- export interface TabHighlightInfo {
11562
- windowId: number;
11538
+ export interface OnHighlightedInfo {
11539
+ /** All highlighted tabs in the window. */
11563
11540
  tabIds: number[];
11564
- }
11565
-
11566
- export interface TabRemoveInfo {
11567
- /**
11568
- * The window whose tab is closed.
11569
- * @since Chrome 25
11570
- */
11541
+ /** The window whose tabs changed. */
11571
11542
  windowId: number;
11572
- /** True when the tab is being closed because its window is being closed. */
11573
- isWindowClosing: boolean;
11574
11543
  }
11575
11544
 
11576
- export interface TabAttachInfo {
11577
- newPosition: number;
11578
- newWindowId: number;
11545
+ export interface OnRemovedInfo {
11546
+ /** True when the tab was closed because its parent window was closed. */
11547
+ isWindowClosing: boolean;
11548
+ /** The window whose tab is closed */
11549
+ windowId: number;
11579
11550
  }
11580
11551
 
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;
11552
+ export interface OnUpdatedInfo {
11553
+ /** The tab's new audible state. */
11554
+ audible?: boolean;
11591
11555
  /**
11592
- * The tab's new audible state.
11593
- * @since Chrome 45
11556
+ * The tab's new auto-discardable state.
11557
+ * @since Chrome 54
11594
11558
  */
11595
- audible?: boolean | undefined;
11559
+ autoDiscardable?: boolean;
11596
11560
  /**
11597
11561
  * The tab's new discarded state.
11598
11562
  * @since Chrome 54
11599
11563
  */
11600
- discarded?: boolean | undefined;
11564
+ discarded?: boolean;
11565
+ /** The tab's new favicon URL. */
11566
+ favIconUrl?: string;
11601
11567
  /**
11602
- * The tab's new auto-discardable
11603
- * @since Chrome 54
11568
+ * The tab's new frozen state.
11569
+ * @since Chrome 132
11604
11570
  */
11605
- autoDiscardable?: boolean | undefined;
11571
+ frozen?: boolean;
11606
11572
  /**
11607
11573
  * The tab's new group.
11608
11574
  * @since Chrome 88
11609
11575
  */
11610
- groupId?: number | undefined;
11576
+ groupId?: number;
11611
11577
  /**
11612
11578
  * The tab's new muted state and the reason for the change.
11613
11579
  * @since Chrome 46
11614
11580
  */
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;
11581
+ mutedInfo?: MutedInfo;
11582
+ /** The tab's new pinned state. */
11583
+ pinned?: boolean;
11584
+ /** The tab's loading status. */
11585
+ status?: `${TabStatus}`;
11626
11586
  /**
11627
11587
  * The tab's new title.
11628
11588
  * @since Chrome 48
11629
11589
  */
11630
- title?: string | undefined;
11590
+ title?: string;
11591
+ /** The tab's URL if it has changed. */
11592
+ url?: string;
11593
+ }
11594
+
11595
+ export interface OnAttachedInfo {
11596
+ newPosition: number;
11597
+ newWindowId: number;
11631
11598
  }
11632
11599
 
11633
- export interface TabMoveInfo {
11600
+ export interface OnMovedInfo {
11601
+ fromIndex: number;
11634
11602
  toIndex: number;
11635
11603
  windowId: number;
11636
- fromIndex: number;
11637
11604
  }
11638
11605
 
11639
- export interface TabDetachInfo {
11640
- oldWindowId: number;
11606
+ export interface OnDetachedInfo {
11641
11607
  oldPosition: number;
11608
+ oldWindowId: number;
11642
11609
  }
11643
11610
 
11644
- export interface TabActiveInfo {
11611
+ export interface OnActivatedInfo {
11645
11612
  /** The ID of the tab that has become active. */
11646
11613
  tabId: number;
11647
11614
  /** The ID of the window the active tab changed inside of. */
11648
11615
  windowId: number;
11649
11616
  }
11650
11617
 
11651
- export interface TabWindowInfo {
11652
- /** The ID of the window of where the tab is located. */
11618
+ export interface OnSelectionChangedInfo {
11619
+ /** The ID of the window the selected tab changed inside of. */
11653
11620
  windowId: number;
11654
11621
  }
11655
11622
 
11656
- export interface ZoomChangeInfo {
11657
- tabId: number;
11658
- oldZoomFactor: number;
11659
- newZoomFactor: number;
11660
- zoomSettings: ZoomSettings;
11623
+ export interface OnActiveChangedInfo {
11624
+ /** The ID of the window the selected tab changed inside of. */
11625
+ windowId: number;
11661
11626
  }
11662
11627
 
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
- {}
11628
+ export interface OnHighlightChangedInfo {
11629
+ /** All highlighted tabs in the window. */
11630
+ tabIds: number[];
11631
+ /** The window whose tabs changed. */
11632
+ windowId: number;
11633
+ }
11694
11634
 
11695
- export interface TabZoomChangeEvent extends chrome.events.Event<(ZoomChangeInfo: ZoomChangeInfo) => void> {}
11635
+ export interface OnZoomChangeInfo {
11636
+ newZoomFactor: number;
11637
+ oldZoomFactor: number;
11638
+ tabId: number;
11639
+ zoomSettings: ZoomSettings;
11640
+ }
11696
11641
 
11697
11642
  /**
11698
11643
  * 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.
11644
+ *
11645
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11646
+ *
11647
+ * MV2 only
11648
+ * @param tabId The ID of the tab in which to run the script; defaults to the active tab of the current window.
11649
+ * @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
11650
+ * @deprecated since Chrome 99. Replaced by {@link scripting.executeScript} in Manifest V3.
11723
11651
  */
11652
+ export function executeScript(details: extensionTypes.InjectDetails): Promise<any[] | undefined>;
11724
11653
  export function executeScript(
11725
- tabId: number,
11654
+ tabId: number | undefined,
11655
+ details: extensionTypes.InjectDetails,
11656
+ ): Promise<any[] | undefined>;
11657
+ export function executeScript(details: extensionTypes.InjectDetails, callback: (result?: any[]) => void): void;
11658
+ export function executeScript(
11659
+ tabId: number | undefined,
11726
11660
  details: extensionTypes.InjectDetails,
11727
- callback?: (result: any[]) => void,
11661
+ callback: (result?: any[]) => void,
11728
11662
  ): void;
11729
- /** Retrieves details about the specified tab. */
11730
- export function get(tabId: number, callback: (tab: Tab) => void): void;
11663
+
11731
11664
  /**
11732
- * Retrieves details about the specified tab.
11733
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
11665
+ * Retrieves details about the specified tab
11666
+ *
11667
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11734
11668
  */
11735
11669
  export function get(tabId: number): Promise<Tab>;
11670
+ export function get(tabId: number, callback: (tab: Tab) => void): void;
11671
+
11736
11672
  /**
11737
11673
  * 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).
11674
+ *
11675
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11676
+ *
11677
+ * MV2 only
11678
+ * @deprecated Please use {@link tabs.query} `{windowId: windowId}`.
11758
11679
  */
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;
11680
+ export function getAllInWindow(windowId?: number): Promise<Tab[]>;
11681
+ export function getAllInWindow(callback: (tabs: Tab[]) => void): void;
11682
+ export function getAllInWindow(windowId: number | undefined, callback: (tabs: Tab[]) => void): void;
11683
+
11762
11684
  /**
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).
11685
+ * 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).
11686
+ *
11687
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11765
11688
  */
11766
11689
  export function getCurrent(): Promise<Tab | undefined>;
11690
+ export function getCurrent(callback: (tab?: Tab) => void): void;
11691
+
11767
11692
  /**
11768
11693
  * Gets the tab that is selected in the specified window.
11769
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11694
+ *
11695
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11696
+ *
11697
+ * MV2 only
11698
+ * @param windowId Defaults to the current window.
11699
+ * @deprecated Please use {@link tabs.query} `{active: true}`.
11770
11700
  */
11701
+ export function getSelected(windowId?: number): Promise<Tab>;
11771
11702
  export function getSelected(callback: (tab: Tab) => void): void;
11703
+ export function getSelected(windowId: number | undefined, callback: (tab: Tab) => void): void;
11704
+
11772
11705
  /**
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}.
11706
+ * Creates a new tab.
11707
+ *
11708
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11776
11709
  */
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>;
11791
- /**
11792
- * 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.
11794
- */
11795
- 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
- export function create(createProperties: CreateProperties, callback: (tab: Tab) => void): void;
11710
+ export function create(createProperties: CreateProperties): Promise<Tab>;
11711
+ export function create(createProperties: CreateProperties, callback: (tab: Tab) => void): void;
11712
+
11802
11713
  /**
11803
11714
  * 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.
11715
+ * @param tabId The tab ID to move.
11716
+ * @param tabIds List of tab IDs to move.
11717
+ *
11718
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11806
11719
  */
11807
11720
  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
11721
  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
- */
11722
+ export function move(tabId: number, moveProperties: MoveProperties, callback: (tab: Tab) => void): void;
11827
11723
  export function move(tabIds: number[], moveProperties: MoveProperties, callback: (tabs: Tab[]) => void): void;
11724
+
11828
11725
  /**
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..
11726
+ * Modifies the properties of a tab. Properties that are not specified in `updateProperties` are not modified.
11727
+ *
11728
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11729
+ * @param tabId Defaults to the selected tab of the current window.
11831
11730
  */
11832
11731
  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
- */
11732
+ export function update(tabId: number | undefined, updateProperties: UpdateProperties): Promise<Tab | undefined>;
11838
11733
  export function update(updateProperties: UpdateProperties, callback: (tab?: Tab) => void): void;
11734
+ export function update(
11735
+ tabId: number | undefined,
11736
+ updateProperties: UpdateProperties,
11737
+ callback: (tab?: Tab) => void,
11738
+ ): void;
11739
+
11839
11740
  /**
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.
11741
+ * Closes one or more tabs.
11742
+ *
11743
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11744
+ * @param tabId The tab ID to close.
11745
+ * @param tabIds List of tab IDs to close.
11856
11746
  */
11857
11747
  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
11748
  export function remove(tabIds: number[]): Promise<void>;
11869
- /**
11870
- * Closes several tabs.
11871
- * @param tabIds The list of tabs to close.
11872
- */
11749
+ export function remove(tabId: number, callback: () => void): void;
11873
11750
  export function remove(tabIds: number[], callback: () => void): void;
11751
+
11874
11752
  /**
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.
11753
+ * 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.
11754
+ *
11755
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11756
+ * @param windowId The target window. Defaults to the current window.
11883
11757
  */
11884
11758
  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
11759
  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
11760
  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
- */
11761
+ export function captureVisibleTab(windowId: number, options: extensionTypes.ImageDetails): Promise<string>;
11762
+ export function captureVisibleTab(callback: (dataUrl: string) => void): void;
11763
+ export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void;
11910
11764
  export function captureVisibleTab(
11911
11765
  options: extensionTypes.ImageDetails,
11912
11766
  callback: (dataUrl: string) => void,
11913
11767
  ): 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
11768
  export function captureVisibleTab(
11932
11769
  windowId: number,
11933
11770
  options: extensionTypes.ImageDetails,
11934
11771
  callback: (dataUrl: string) => void,
11935
11772
  ): void;
11773
+
11936
11774
  /**
11937
11775
  * Reload a tab.
11938
- * @since Chrome 16
11776
+ *
11777
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11939
11778
  * @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
11779
  */
11780
+ export function reload(): Promise<void>;
11942
11781
  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
11782
  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
11783
  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
11784
  export function reload(callback: () => void): void;
11785
+ export function reload(tabId: number | undefined, callback: () => void): void;
11786
+ export function reload(reloadProperties: ReloadProperties | undefined, callback: () => void): void;
11787
+ export function reload(
11788
+ tabId: number | undefined,
11789
+ reloadProperties: ReloadProperties | undefined,
11790
+ callback: () => void,
11791
+ ): void;
11792
+
11982
11793
  /**
11983
11794
  * 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).
11795
+ *
11796
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11797
+ * @param tabId The ID of the tab to duplicate.
11987
11798
  */
11988
11799
  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
11800
  export function duplicate(tabId: number, callback: (tab?: Tab) => void): void;
11801
+
11997
11802
  /**
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
11803
+ * 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.
11804
+ *
11805
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
12000
11806
  */
12001
11807
  export function sendMessage<M = any, R = any>(
12002
11808
  tabId: number,
12003
11809
  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
- */
11810
+ options?: MessageSendOptions,
11811
+ ): Promise<R>;
12012
11812
  export function sendMessage<M = any, R = any>(
12013
11813
  tabId: number,
12014
11814
  message: M,
12015
- options: MessageSendOptions,
12016
- responseCallback: (response: R) => void,
11815
+ /** @since Chrome 99 */
11816
+ callback: (response: R) => void,
12017
11817
  ): 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
11818
  export function sendMessage<M = any, R = any>(
12028
11819
  tabId: number,
12029
11820
  message: M,
12030
- options: MessageSendOptions,
12031
- ): Promise<R>;
11821
+ options: MessageSendOptions | undefined,
11822
+ /** @since Chrome 99 */
11823
+ callback: (response: R) => void,
11824
+ ): void;
11825
+
12032
11826
  /**
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.
11827
+ * 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.
11828
+ *
11829
+ * MV2 only
11830
+ * @deprecated Please use {@link runtime.sendMessage}.
12037
11831
  */
12038
11832
  export function sendRequest<Request = any, Response = any>(
12039
11833
  tabId: number,
12040
11834
  request: Request,
12041
- responseCallback?: (response: Response) => void,
11835
+ ): Promise<Response>;
11836
+ export function sendRequest<Request = any, Response = any>(
11837
+ tabId: number,
11838
+ request: Request,
11839
+ /** @since Chrome 99 */
11840
+ callback?: (response: Response) => void,
12042
11841
  ): 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;
11842
+
12045
11843
  /**
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.
11844
+ * 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.
11845
+ * @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
11846
  */
12050
- export function insertCSS(details: extensionTypes.InjectDetails): Promise<void>;
11847
+ export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port;
11848
+
12051
11849
  /**
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.
11850
+ * 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.
11851
+ *
11852
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11853
+ *
11854
+ * MV2 only
11855
+ * @param tabId The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
11856
+ * @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.
11857
+ * @deprecated since Chrome 99. Replaced by {@link scripting.insertCSS} in Manifest V3.
12055
11858
  */
11859
+ export function insertCSS(details: extensionTypes.InjectDetails): Promise<void>;
11860
+ export function insertCSS(tabId: number | undefined, details: extensionTypes.InjectDetails): Promise<void>;
12056
11861
  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
- */
11862
+ export function insertCSS(tabId: number | undefined, details: extensionTypes.InjectDetails): Promise<void>;
12070
11863
  export function insertCSS(tabId: number, details: extensionTypes.InjectDetails, callback: () => void): void;
11864
+
12071
11865
  /**
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).
11866
+ * Highlights the given tabs and focuses on the first of group. Will appear to do nothing if the specified tab is currently active.
11867
+ *
11868
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
12096
11869
  */
11870
+ export function highlight(highlightInfo: HighlightInfo): Promise<windows.Window>;
11871
+ export function highlight(highlightInfo: HighlightInfo, callback: (window: windows.Window) => void): void;
11872
+
11873
+ /** Gets all tabs that have the specified properties, or all tabs if no properties are specified. */
12097
11874
  export function query(queryInfo: QueryInfo): Promise<Tab[]>;
11875
+ export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void;
11876
+
12098
11877
  /**
12099
11878
  * 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.
11879
+ *
11880
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11881
+ * @param tabId The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12102
11882
  */
11883
+ export function detectLanguage(tabId?: number): Promise<string>;
12103
11884
  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>;
11885
+ export function detectLanguage(tabId: number | undefined, callback: (language: string) => void): void;
11886
+
12122
11887
  /**
12123
11888
  * 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.
11889
+ *
11890
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11891
+ * @param tabId The ID of the tab to zoom; defaults to the active tab of the current window.
11892
+ * @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
11893
  */
12128
11894
  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
- */
11895
+ export function setZoom(tabId: number | undefined, zoomFactor: number): Promise<void>;
12135
11896
  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;
11897
+ export function setZoom(tabId: number | undefined, zoomFactor: number, callback: () => void): void;
11898
+
12152
11899
  /**
12153
11900
  * 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.
11901
+ *
11902
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11903
+ * @param tabId The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12157
11904
  */
11905
+ export function getZoom(tabId?: number): Promise<number>;
12158
11906
  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>;
11907
+ export function getZoom(tabId: number | undefined, callback: (zoomFactor: number) => void): void;
11908
+
12180
11909
  /**
12181
11910
  * 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
11911
+ *
11912
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11913
+ * @param tabId The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12183
11914
  * @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
11915
  */
12186
11916
  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
- */
11917
+ export function setZoomSettings(tabId: number | undefined, zoomSettings: ZoomSettings): Promise<void>;
12193
11918
  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;
11919
+ export function setZoomSettings(
11920
+ tabId: number | undefined,
11921
+ zoomSettings: ZoomSettings,
11922
+ callback: () => void,
11923
+ ): void;
11924
+
12210
11925
  /**
12211
11926
  * 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.
11927
+ *
11928
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11929
+ * @param tabId The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12215
11930
  */
11931
+ export function getZoomSettings(tabId?: number): Promise<ZoomSettings>;
12216
11932
  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>;
11933
+ export function getZoomSettings(
11934
+ tabId: number | undefined,
11935
+ callback: (zoomSettings: ZoomSettings) => void,
11936
+ ): void;
11937
+
12245
11938
  /**
12246
11939
  * Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
11940
+ *
11941
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11942
+ * @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
11943
  * @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
11944
  */
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>;
11945
+ export function discard(tabId?: number): Promise<Tab | undefined>;
11946
+ export function discard(callback: (tab?: Tab) => void): void;
11947
+ export function discard(tabId: number | undefined, callback: (tab?: Tab) => void): void;
11948
+
12259
11949
  /**
12260
11950
  * Go forward to the next page, if one is available.
11951
+ *
11952
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11953
+ * @param tabId The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12261
11954
  * @since Chrome 72
12262
- * @param callback Optional. Called after the operation is completed.
12263
11955
  */
11956
+ export function goForward(tabId?: number): Promise<void>;
12264
11957
  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>;
11958
+ export function goForward(tabId: number | undefined, callback: () => void): void;
11959
+
12285
11960
  /**
12286
11961
  * Go back to the previous page, if one is available.
11962
+ *
11963
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11964
+ * @param tabId The ID of the tab to navigate back; defaults to the selected tab of the current window.
12287
11965
  * @since Chrome 72
12288
- * @param callback Optional. Called after the operation is completed.
12289
11966
  */
11967
+ export function goBack(tabId?: number): Promise<void>;
12290
11968
  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>;
11969
+ export function goBack(tabId: number | undefined, callback: () => void): void;
11970
+
12312
11971
  /**
12313
11972
  * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
11973
+ *
11974
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
12314
11975
  * @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
11976
  */
12318
11977
  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
11978
  export function group(options: GroupOptions, callback: (groupId: number) => void): void;
11979
+
12326
11980
  /**
12327
11981
  * Removes one or more tabs from their respective groups. If any groups become empty, they are deleted
11982
+ *
11983
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11984
+ * @param tabIds The tab ID or list of tab IDs to remove from their respective groups.
12328
11985
  * @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
11986
  */
12344
- export var onHighlighted: TabHighlightedEvent;
11987
+ export function ungroup(tabIds: number | [number, ...number[]]): Promise<void>;
11988
+ export function ungroup(tabIds: number | [number, ...number[]], callback: () => void): void;
11989
+
11990
+ /** Fired when the highlighted or selected tabs in a window changes */
11991
+ export const onHighlighted: events.Event<
11992
+ (highlightInfo: OnHighlightedInfo) => void
11993
+ >;
11994
+
12345
11995
  /** Fired when a tab is closed. */
12346
- export var onRemoved: TabRemovedEvent;
11996
+ export const onRemoved: events.Event<
11997
+ (tabId: number, removeInfo: OnRemovedInfo) => void
11998
+ >;
11999
+
12347
12000
  /** Fired when a tab is updated. */
12348
- export var onUpdated: TabUpdatedEvent;
12001
+ export const onUpdated: events.Event<
12002
+ (tabId: number, changeInfo: OnUpdatedInfo, tab: Tab) => void
12003
+ >;
12004
+
12349
12005
  /** 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;
12006
+ export const onAttached: events.Event<
12007
+ (tabId: number, attachInfo: OnAttachedInfo) => void
12008
+ >;
12009
+
12010
+ /** 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}. */
12011
+ export const onMoved: events.Event<
12012
+ (tabId: number, moveInfo: OnMovedInfo) => void
12013
+ >;
12014
+
12015
+ /** Fired when a tab is detached from a window; for example, because it was moved between windows. */
12016
+ export const onDetached: events.Event<
12017
+ (tabId: number, detachInfo: OnDetachedInfo) => void
12018
+ >;
12019
+
12020
+ /** 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. */
12021
+ export const onCreated: events.Event<(tab: Tab) => void>;
12022
+
12023
+ /** 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 */
12024
+ export const onActivated: events.Event<
12025
+ (activeInfo: OnActivatedInfo) => void
12026
+ >;
12027
+
12028
+ /** Fired when a tab is replaced with another tab due to prerendering or instant */
12029
+ export const onReplaced: events.Event<
12030
+ (addedTabId: number, removedTabId: number) => void
12031
+ >;
12032
+
12369
12033
  /**
12370
- * @deprecated since Chrome 33. Please use tabs.onActivated.
12371
12034
  * Fires when the selected tab in a window changes.
12035
+ *
12036
+ * MV2 only
12037
+ * @deprecated Please use {@link tabs.onActivated}.
12372
12038
  */
12373
- export var onSelectionChanged: TabSelectedEvent;
12039
+ export const onSelectionChanged: events.Event<
12040
+ (tabId: number, selectInfo: OnSelectionChangedInfo) => void
12041
+ >;
12042
+
12374
12043
  /**
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.
12044
+ * 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.
12045
+ *
12046
+ * MV2 only
12047
+ * @deprecated Please use {@link tabs.onActivated}.
12377
12048
  */
12378
- export var onActiveChanged: TabSelectedEvent;
12049
+ export const onActiveChanged: events.Event<
12050
+ (tabId: number, selectInfo: OnActiveChangedInfo) => void
12051
+ >;
12052
+
12379
12053
  /**
12380
- * @deprecated since Chrome 33. Please use tabs.onHighlighted.
12381
12054
  * Fired when the highlighted or selected tabs in a window changes.
12055
+ *
12056
+ * MV2 only
12057
+ * @deprecated Please use {@link tabs.onHighlighted}.
12382
12058
  */
12383
- export var onHighlightChanged: TabHighlightedEvent;
12384
- /**
12385
- * Fired when a tab is zoomed.
12386
- * @since Chrome 38
12387
- */
12388
- export var onZoomChange: TabZoomChangeEvent;
12059
+ export const onHighlightChanged: events.Event<
12060
+ (selectInfo: OnHighlightChangedInfo) => void
12061
+ >;
12389
12062
 
12390
- /**
12391
- * An ID which represents the absence of a browser tab.
12392
- * @since Chrome 46
12393
- */
12394
- export var TAB_ID_NONE: -1;
12063
+ /** Fired when a tab is zoomed */
12064
+ export const onZoomChange: events.Event<
12065
+ (ZoomChangeInfo: OnZoomChangeInfo) => void
12066
+ >;
12395
12067
  }
12396
12068
 
12397
12069
  ////////////////////