@wxt-dev/browser 0.0.329 → 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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/gen/index.d.ts +649 -950
@@ -8941,11 +8941,13 @@ export namespace Browser {
8941
8941
  * Use the `Browser.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.
8942
8942
  */
8943
8943
  export namespace runtime {
8944
- /** 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. */
8945
- export const lastError: {
8944
+ export interface LastError {
8946
8945
  /** Details about the error which occurred. */
8947
8946
  message?: string;
8948
- } | undefined;
8947
+ }
8948
+
8949
+ /** 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. */
8950
+ export const lastError: LastError | undefined;
8949
8951
 
8950
8952
  /** The ID of the extension/app. */
8951
8953
  export const id: string;
@@ -9173,6 +9175,11 @@ export namespace Browser {
9173
9175
  name: string;
9174
9176
  }
9175
9177
 
9178
+ export interface UpdateAvailableDetails {
9179
+ /** The version number of the available update. */
9180
+ version: string;
9181
+ }
9182
+
9176
9183
  export interface UpdateCheckDetails {
9177
9184
  /** The version of the available update. */
9178
9185
  version: string;
@@ -9652,7 +9659,7 @@ export namespace Browser {
9652
9659
  */
9653
9660
  export function requestUpdateCheck(): Promise<RequestUpdateCheckResult>;
9654
9661
  export function requestUpdateCheck(
9655
- callback: (status: `${RequestUpdateCheckStatus}`, details?: { version: string }) => void,
9662
+ callback: (status: `${RequestUpdateCheckStatus}`, details?: UpdateCheckDetails) => void,
9656
9663
  ): void;
9657
9664
 
9658
9665
  /** Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op. */
@@ -9771,7 +9778,7 @@ export namespace Browser {
9771
9778
  export const onRestartRequired: events.Event<(reason: `${OnRestartRequiredReason}`) => void>;
9772
9779
 
9773
9780
  /** 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 Browser.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call Browser.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 Browser.runtime.reload() is called in response to this event. */
9774
- export const onUpdateAvailable: events.Event<(details: { version: string }) => void>;
9781
+ export const onUpdateAvailable: events.Event<(details: UpdateAvailableDetails) => void>;
9775
9782
 
9776
9783
  /**
9777
9784
  * Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required.
@@ -9804,11 +9811,22 @@ export namespace Browser {
9804
9811
  * @since Chrome 88, MV3
9805
9812
  */
9806
9813
  export namespace scripting {
9807
- /* The CSS style origin for a style change. */
9808
- export type StyleOrigin = "AUTHOR" | "USER";
9814
+ /** The origin for a style change. See style origins for more info. */
9815
+ export enum StyleOrigin {
9816
+ AUTHOR = "AUTHOR",
9817
+ USER = "USER",
9818
+ }
9809
9819
 
9810
- /* The JavaScript world for a script to execute within. */
9811
- export type ExecutionWorld = "ISOLATED" | "MAIN";
9820
+ /**
9821
+ * The JavaScript world for a script to execute within.
9822
+ * @since Chrome 95
9823
+ */
9824
+ export enum ExecutionWorld {
9825
+ /** Specifies the isolated world, which is the execution environment unique to this extension. */
9826
+ ISOLATED = "ISOLATED",
9827
+ /** Specifies the main world of the DOM, which is the execution environment shared with the host page's JavaScript. */
9828
+ MAIN = "MAIN",
9829
+ }
9812
9830
 
9813
9831
  export interface InjectionResult<T extends any = any> {
9814
9832
  /**
@@ -9821,100 +9839,162 @@ export namespace Browser {
9821
9839
  * @since Chrome 90
9822
9840
  */
9823
9841
  frameId: number;
9824
- /* The result of the script execution. */
9825
- result?: T | undefined;
9842
+ /** The result of the script execution. */
9843
+ result?: T;
9826
9844
  }
9827
9845
 
9828
- export interface InjectionTarget {
9829
- /* Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if frameIds is specified. */
9830
- allFrames?: boolean | undefined;
9831
- /**
9832
- * The IDs of specific documentIds to inject into. This must not be set if frameIds is set.
9833
- * @since Chrome 106
9834
- */
9835
- documentIds?: string[] | undefined;
9836
- /* The IDs of specific frames to inject into. */
9837
- frameIds?: number[] | undefined;
9838
- /* The ID of the tab into which to inject. */
9839
- tabId: number;
9840
- }
9846
+ export type InjectionTarget =
9847
+ & {
9848
+ /** The ID of the tab into which to inject. */
9849
+ tabId: number;
9850
+ }
9851
+ & (
9852
+ | {
9853
+ /** Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if `frameIds` or `documentIds` is specified. */
9854
+ allFrames?: boolean | undefined;
9855
+ /**
9856
+ * The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set.
9857
+ * @since Chrome 106
9858
+ */
9859
+ documentIds?: never | undefined;
9860
+ /** The IDs of specific frames to inject into. */
9861
+ frameIds?: never | undefined;
9862
+ }
9863
+ | {
9864
+ /** Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if `frameIds` or `documentIds` is specified. */
9865
+ allFrames?: false | undefined;
9866
+ /**
9867
+ * The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set.
9868
+ * @since Chrome 106
9869
+ */
9870
+ documentIds?: never | undefined;
9871
+ /** The IDs of specific frames to inject into. */
9872
+ frameIds: number[] | undefined;
9873
+ }
9874
+ | {
9875
+ /** Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if `frameIds` or `documentIds` is specified. */
9876
+ allFrames?: false | undefined;
9877
+ /**
9878
+ * The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set.
9879
+ * @since Chrome 106
9880
+ */
9881
+ documentIds?: string[] | undefined;
9882
+ /** The IDs of specific frames to inject into. */
9883
+ frameIds?: never | undefined;
9884
+ }
9885
+ );
9841
9886
 
9842
- export interface CSSInjection {
9843
- /* A string containing the CSS to inject. Exactly one of files and css must be specified. */
9844
- css?: string | undefined;
9845
- /* The path of the CSS files to inject, relative to the extension's root directory. NOTE: Currently a maximum of one file is supported. Exactly one of files and css must be specified. */
9846
- files?: string[] | undefined;
9847
- /* The style origin for the injection. Defaults to 'AUTHOR'. */
9848
- origin?: StyleOrigin | undefined;
9849
- /* Details specifying the target into which to insert the CSS. */
9850
- target: InjectionTarget;
9851
- }
9887
+ export type CSSInjection =
9888
+ & {
9889
+ /** The style origin for the injection. Defaults to `'AUTHOR'`. */
9890
+ origin?: `${StyleOrigin}` | undefined;
9891
+ /** Details specifying the target into which to insert the CSS. */
9892
+ target: InjectionTarget;
9893
+ }
9894
+ & (
9895
+ | {
9896
+ /** A string containing the CSS to inject. Exactly one of `files` and `css` must be specified. */
9897
+ css: string;
9898
+ /** The path of the CSS files to inject, relative to the extension's root directory. Exactly one of `files` and `css` must be specified. */
9899
+ files?: never | undefined;
9900
+ }
9901
+ | {
9902
+ /** A string containing the CSS to inject. Exactly one of `files` and `css` must be specified. */
9903
+ css?: never | undefined;
9904
+ /** The path of the CSS files to inject, relative to the extension's root directory. Exactly one of `files` and `css` must be specified. */
9905
+ files: string[];
9906
+ }
9907
+ );
9852
9908
 
9853
9909
  export type ScriptInjection<Args extends any[], Result> =
9854
9910
  & {
9855
- /* Details specifying the target into which to inject the script. */
9911
+ /** Details specifying the target into which to inject the script. */
9856
9912
  target: InjectionTarget;
9857
- /* The JavaScript world for a script to execute within. */
9858
- world?: ExecutionWorld;
9859
- /* Whether the injection should be triggered in the target as soon as possible. Note that this is not a guarantee that injection will occur prior to page load, as the page may have already loaded by the time the script reaches the target. */
9913
+ /** The JavaScript "world" to run the script in. Defaults to `ISOLATED`. */
9914
+ world?: `${ExecutionWorld}`;
9915
+ /**
9916
+ * Whether the injection should be triggered in the target as soon as possible. Note that this is not a guarantee that injection will occur prior to page load, as the page may have already loaded by the time the script reaches the target.
9917
+ * @since Chrome 102
9918
+ */
9860
9919
  injectImmediately?: boolean;
9861
9920
  }
9862
9921
  & (
9863
9922
  | {
9864
- /* The path of the JS files to inject, relative to the extension's root directory. NOTE: Currently a maximum of one file is supported. Exactly one of files and function must be specified. */
9923
+ /** A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of `files` or `func` must be specified. */
9924
+ func?: never | undefined;
9925
+ /** The path of the JS or CSS files to inject, relative to the extension's root directory. Exactly one of files or func must be specified. */
9865
9926
  files: string[];
9866
9927
  }
9867
9928
  | ({
9868
- /* A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of files and function must be specified. */
9929
+ /** A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of `files` or `func` must be specified. */
9869
9930
  func: () => Result;
9931
+ /** The path of the JS or CSS files to inject, relative to the extension's root directory. Exactly one of files or func must be specified. */
9932
+ files?: never | undefined;
9870
9933
  } | {
9871
- /* A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of files and function must be specified. */
9872
- func: (...args: Args) => Result;
9873
- /* The arguments to carry into a provided function. This is only valid if the func parameter is specified. These arguments must be JSON-serializable. */
9934
+ /** The arguments to pass to the provided function. This is only valid if the `func` parameter is specified. These arguments must be JSON-serializable. */
9874
9935
  args: Args;
9936
+ /** A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of `files` or `func` must be specified. */
9937
+ func: (...args: Args) => Result;
9938
+ /** The path of the JS or CSS files to inject, relative to the extension's root directory. Exactly one of files or func must be specified. */
9939
+ files?: never | undefined;
9875
9940
  })
9876
9941
  );
9877
9942
 
9878
9943
  type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
9879
9944
 
9880
- interface RegisteredContentScript {
9881
- id: string;
9882
- allFrames?: boolean;
9883
- matchOriginAsFallback?: boolean;
9884
- css?: string[];
9885
- excludeMatches?: string[];
9886
- js?: string[];
9887
- matches?: string[];
9888
- persistAcrossSessions?: boolean;
9889
- runAt?: extensionTypes.RunAt;
9890
- world?: ExecutionWorld;
9891
- }
9945
+ /** @since Chrome 96 */
9946
+ type RegisteredContentScript =
9947
+ & {
9948
+ /** The id of the content script, specified in the API call. Must not start with a '_' as it's reserved as a prefix for generated script IDs. */
9949
+ id: string;
9950
+ /** If specified true, it will inject into all frames, even if the frame is not the top-most frame in the tab. Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched. */
9951
+ allFrames?: boolean | undefined;
9952
+ /** Excludes pages that this content script would otherwise be injected into. See Match Patterns for more details on the syntax of these strings. */
9953
+ excludeMatches?: string[] | undefined;
9954
+ /**
9955
+ * Indicates whether the script can be injected into frames where the URL contains an unsupported scheme; specifically: about:, data:, blob:, or filesystem:. In these cases, the URL's origin is checked to determine if the script should be injected. If the origin is `null` (as is the case for data: URLs) then the used origin is either the frame that created the current frame or the frame that initiated the navigation to this frame. Note that this may not be the parent frame.
9956
+ * @since Chrome 119
9957
+ */
9958
+ matchOriginAsFallback?: boolean | undefined;
9959
+ /** Specifies which pages this content script will be injected into. See Match Patterns for more details on the syntax of these strings. Must be specified for {@link registerContentScripts}. */
9960
+ matches?: string[] | undefined;
9961
+ /** Specifies if this content script will persist into future sessions. The default is true. */
9962
+ persistAcrossSessions?: boolean | undefined;
9963
+ /** Specifies when JavaScript files are injected into the web page. The preferred and default value is `document_idle`. */
9964
+ runAt?: extensionTypes.RunAt | undefined;
9965
+ /** The JavaScript "world" to run the script in. Defaults to `ISOLATED`. */
9966
+ world?: `${ExecutionWorld}` | undefined;
9967
+ }
9968
+ & (
9969
+ | {
9970
+ /** The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. */
9971
+ js: string[];
9972
+ /** The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array, before any DOM is constructed or displayed for the page. */
9973
+ css?: string[] | undefined;
9974
+ }
9975
+ | {
9976
+ /** The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. */
9977
+ js?: string[] | undefined;
9978
+ /** The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array, before any DOM is constructed or displayed for the page. */
9979
+ css: string[];
9980
+ }
9981
+ );
9892
9982
 
9893
- interface ContentScriptFilter {
9894
- ids?: string[];
9895
- css?: string;
9896
- files?: string[];
9897
- origin?: StyleOrigin;
9898
- target?: InjectionTarget;
9983
+ /** @since Chrome 96 */
9984
+ export interface ContentScriptFilter {
9985
+ /** If specified, {@link getRegisteredContentScripts} will only return scripts with an id specified in this list. */
9986
+ ids?: string[] | undefined;
9899
9987
  }
9900
9988
 
9901
9989
  /**
9902
- * Injects a script into a target context. The script will be run at document_end.
9903
- * @param injection
9904
- * The details of the script which to inject.
9905
- * @return The `executeScript` method provides its result via callback or returned as a `Promise` (MV3 only). The resulting array contains the result of execution for each frame where the injection succeeded.
9990
+ * Injects a script into a target context. By default, the script will be run at `document_idle`, or immediately if the page has already loaded. If the `injectImmediately` property is set, the script will inject without waiting, even if the page has not finished loading. If the script evaluates to a promise, the browser will wait for the promise to settle and return the resulting value.
9991
+ *
9992
+ * Can return its result via Promise since Chrome 90.
9993
+ * @param injection The details of the script which to inject.
9906
9994
  */
9907
9995
  export function executeScript<Args extends any[], Result>(
9908
9996
  injection: ScriptInjection<Args, Result>,
9909
9997
  ): Promise<Array<InjectionResult<Awaited<Result>>>>;
9910
-
9911
- /**
9912
- * Injects a script into a target context. The script will be run at document_end.
9913
- * @param injection
9914
- * The details of the script which to inject.
9915
- * @param callback
9916
- * Invoked upon completion of the injection. The resulting array contains the result of execution for each frame where the injection succeeded.
9917
- */
9918
9998
  export function executeScript<Args extends any[], Result>(
9919
9999
  injection: ScriptInjection<Args, Result>,
9920
10000
  callback: (results: Array<InjectionResult<Awaited<Result>>>) => void,
@@ -9922,102 +10002,56 @@ export namespace Browser {
9922
10002
 
9923
10003
  /**
9924
10004
  * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored.
9925
- * @param injection
9926
- * The details of the styles to insert.
9927
- * @return The `insertCSS` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
10005
+ *
10006
+ * Can return its result via Promise since Chrome 90.
10007
+ * @param injection The details of the styles to insert.
9928
10008
  */
9929
10009
  export function insertCSS(injection: CSSInjection): Promise<void>;
9930
-
9931
- /**
9932
- * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored.
9933
- * @param injection
9934
- * The details of the styles to insert.
9935
- * @param callback
9936
- * Invoked upon completion of the injection.
9937
- */
9938
10010
  export function insertCSS(injection: CSSInjection, callback: () => void): void;
9939
10011
 
9940
10012
  /**
9941
10013
  * Removes a CSS stylesheet that was previously inserted by this extension from a target context.
9942
- * @param injection
9943
- * The details of the styles to remove.
9944
- * Note that the css, files, and origin properties must exactly match the stylesheet inserted through `insertCSS`.
9945
- * Attempting to remove a non-existent stylesheet is a no-op.
9946
- * @return This only returns a Promise when the callback parameter is not specified, and with MV3.
10014
+ * @param injection The details of the styles to remove. Note that the `css`, `files`, and `origin` properties must exactly match the stylesheet inserted through {@link insertCSS}. Attempting to remove a non-existent stylesheet is a no-op.
9947
10015
  * @since Chrome 90
9948
10016
  */
9949
10017
  export function removeCSS(injection: CSSInjection): Promise<void>;
9950
-
9951
- /**
9952
- * Removes a CSS stylesheet that was previously inserted by this extension from a target context.
9953
- * @param injection
9954
- * The details of the styles to remove.
9955
- * Note that the css, files, and origin properties must exactly match the stylesheet inserted through `insertCSS`.
9956
- * Attempting to remove a non-existent stylesheet is a no-op.
9957
- * @param callback
9958
- * Invoked upon completion of the removal.
9959
- * @since Chrome 90
9960
- */
9961
10018
  export function removeCSS(injection: CSSInjection, callback: () => void): void;
9962
10019
 
9963
10020
  /**
9964
- * Registers one or more content scripts.
9965
- * @param scripts
10021
+ * Registers one or more content scripts for this extension
10022
+ * @param scripts Contains a list of scripts to be registered. If there are errors during script parsing/file validation, or if the IDs specified already exist, then no scripts are registered.
10023
+ * @since Chrome 96
9966
10024
  */
9967
10025
  export function registerContentScripts(scripts: RegisteredContentScript[]): Promise<void>;
9968
-
9969
- /**
9970
- * Registers one or more content scripts.
9971
- * @param scripts
9972
- * @param callback
9973
- */
9974
10026
  export function registerContentScripts(scripts: RegisteredContentScript[], callback: () => void): void;
9975
10027
 
9976
10028
  /**
9977
- * Unregister one or more content scripts.
9978
- * @param filter
9979
- * @param callback
10029
+ * Unregisters content scripts for this extension.
10030
+ * @param filter If specified, only unregisters dynamic content scripts which match the filter. Otherwise, all of the extension's dynamic content scripts are unregistered.
10031
+ * @since Chrome 96
9980
10032
  */
9981
10033
  export function unregisterContentScripts(filter?: ContentScriptFilter): Promise<void>;
9982
-
9983
- /**
9984
- * Unregister one or more content scripts.
9985
- * @param filter
9986
- * @param callback
9987
- */
9988
10034
  export function unregisterContentScripts(callback: () => void): void;
9989
- export function unregisterContentScripts(filter: ContentScriptFilter, callback: () => void): void;
10035
+ export function unregisterContentScripts(filter: ContentScriptFilter | undefined, callback: () => void): void;
9990
10036
 
9991
10037
  /**
9992
- * Returns all the content scripts registered with scripting.registerContentScripts()
9993
- * or a subset of the registered scripts when using a filter.
9994
- * @param filter
10038
+ * Returns all dynamically registered content scripts for this extension that match the given filter.
10039
+ * @param filter An object to filter the extension's dynamically registered scripts.
10040
+ * @since Chrome 96
9995
10041
  */
9996
10042
  export function getRegisteredContentScripts(filter?: ContentScriptFilter): Promise<RegisteredContentScript[]>;
9997
-
9998
- /**
9999
- * Returns all the content scripts registered with scripting.registerContentScripts()
10000
- * or a subset of the registered scripts when using a filter.
10001
- * @param filter
10002
- * @param callback
10003
- */
10004
10043
  export function getRegisteredContentScripts(callback: (scripts: RegisteredContentScript[]) => void): void;
10005
10044
  export function getRegisteredContentScripts(
10006
- filter: ContentScriptFilter,
10045
+ filter: ContentScriptFilter | undefined,
10007
10046
  callback: (scripts: RegisteredContentScript[]) => void,
10008
10047
  ): void;
10009
10048
 
10010
10049
  /**
10011
- * Updates one or more content scripts.
10012
- * @param scripts
10050
+ * Updates one or more content scripts for this extension.
10051
+ * @param scripts Contains a list of scripts to be updated. A property is only updated for the existing script if it is specified in this object. If there are errors during script parsing/file validation, or if the IDs specified do not correspond to a fully registered script, then no scripts are updated.
10052
+ * @since Chrome 96
10013
10053
  */
10014
10054
  export function updateContentScripts(scripts: RegisteredContentScript[]): Promise<void>;
10015
-
10016
- /**
10017
- * Updates one or more content scripts.
10018
- * @param scripts
10019
- * @param callback
10020
- */
10021
10055
  export function updateContentScripts(scripts: RegisteredContentScript[], callback: () => void): void;
10022
10056
  }
10023
10057
 
@@ -11173,67 +11207,54 @@ export namespace Browser {
11173
11207
  */
11174
11208
  export namespace tabs {
11175
11209
  /**
11176
- * Tab muted state and the reason for the last state change.
11210
+ * The tab's muted state and the reason for the last state change.
11177
11211
  * @since Chrome 46
11178
11212
  */
11179
11213
  export interface MutedInfo {
11180
- /** Whether the tab is prevented from playing sound (but hasn't necessarily recently produced sound). Equivalent to whether the muted audio indicator is showing. */
11214
+ /** 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. */
11181
11215
  muted: boolean;
11182
- /**
11183
- * Optional.
11184
- * The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed.
11185
- * "user": A user input action has set/overridden the muted state.
11186
- * "capture": Tab capture started, forcing a muted state change.
11187
- * "extension": An extension, identified by the extensionId field, set the muted state.
11188
- */
11189
- reason?: string | undefined;
11190
- /**
11191
- * Optional.
11192
- * The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed.
11193
- */
11216
+ /* The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed. */
11217
+ reason?: `${MutedInfoReason}` | undefined;
11218
+ /** The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed. */
11194
11219
  extensionId?: string | undefined;
11195
11220
  }
11196
11221
 
11222
+ /**
11223
+ * An event that caused a muted state change.
11224
+ * @since Chrome 46
11225
+ */
11226
+ export enum MutedInfoReason {
11227
+ /** A user input action set the muted state. */
11228
+ USER = "user",
11229
+ /** Tab capture was started, forcing a muted state change. */
11230
+ CAPTURE = "capture",
11231
+ /** An extension set the muted state. */
11232
+ EXTENSION = "extension",
11233
+ }
11234
+
11197
11235
  export interface Tab {
11198
- /**
11199
- * Optional.
11200
- * Either loading or complete.
11201
- */
11202
- status?: string | undefined;
11236
+ /** The tab's loading status. */
11237
+ status?: `${TabStatus}` | undefined;
11203
11238
  /** The zero-based index of the tab within its window. */
11204
11239
  index: number;
11205
- /**
11206
- * Optional.
11207
- * The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.
11208
- * @since Chrome 18
11209
- */
11240
+ /** The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists. */
11210
11241
  openerTabId?: number | undefined;
11211
- /** The title of the tab. This property is only present if the extension has the `tabs` permission or has host permissions for the page. */
11242
+ /** The title of the tab. This property is only present if the extension has the `"tabs"` permission or has host permissions for the page. */
11212
11243
  title?: string | undefined;
11213
- /** 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}. */
11244
+ /** 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}. */
11214
11245
  url?: string | undefined;
11215
11246
  /**
11216
- * 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.
11217
- * This property is only present if the extension's manifest includes the "tabs" permission and there is a pending navigation.
11247
+ * 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.
11218
11248
  * @since Chrome 79
11219
11249
  */
11220
11250
  pendingUrl?: string | undefined;
11221
- /**
11222
- * Whether the tab is pinned.
11223
- * @since Chrome 9
11224
- */
11251
+ /** Whether the tab is pinned. */
11225
11252
  pinned: boolean;
11226
- /**
11227
- * Whether the tab is highlighted.
11228
- * @since Chrome 16
11229
- */
11253
+ /** Whether the tab is highlighted. */
11230
11254
  highlighted: boolean;
11231
- /** The ID of the window the tab is contained within. */
11255
+ /** The ID of the window that contains the tab. */
11232
11256
  windowId: number;
11233
- /**
11234
- * Whether the tab is active in its window. (Does not necessarily mean the window is focused.)
11235
- * @since Chrome 16
11236
- */
11257
+ /** Whether the tab is active in its window. Does not necessarily mean the window is focused. */
11237
11258
  active: boolean;
11238
11259
  /** 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. */
11239
11260
  favIconUrl?: string | undefined;
@@ -11242,26 +11263,22 @@ export namespace Browser {
11242
11263
  * @since Chrome 132
11243
11264
  */
11244
11265
  frozen: boolean;
11245
- /**
11246
- * Optional.
11247
- * 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 Browser.tabs.TAB_ID_NONE for apps and devtools windows.
11248
- */
11266
+ /** 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 `Browser.tabs.TAB_ID_NONE` for apps and devtools windows. */
11249
11267
  id?: number | undefined;
11250
11268
  /** Whether the tab is in an incognito window. */
11251
11269
  incognito: boolean;
11252
11270
  /**
11253
11271
  * Whether the tab is selected.
11254
- * @deprecated since Chrome 33. Please use tabs.Tab.highlighted.
11272
+ * @deprecated since Chrome 33. Please use {@link Tab.highlighted}.
11255
11273
  */
11256
11274
  selected: boolean;
11257
11275
  /**
11258
- * Optional.
11259
- * 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.
11276
+ * 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.
11260
11277
  * @since Chrome 45
11261
11278
  */
11262
11279
  audible?: boolean | undefined;
11263
11280
  /**
11264
- * 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.
11281
+ * 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.
11265
11282
  * @since Chrome 54
11266
11283
  */
11267
11284
  discarded: boolean;
@@ -11271,25 +11288,15 @@ export namespace Browser {
11271
11288
  */
11272
11289
  autoDiscardable: boolean;
11273
11290
  /**
11274
- * Optional.
11275
- * Current tab muted state and the reason for the last state change.
11291
+ * The tab's muted state and the reason for the last state change.
11276
11292
  * @since Chrome 46
11277
11293
  */
11278
11294
  mutedInfo?: MutedInfo | undefined;
11279
- /**
11280
- * Optional. The width of the tab in pixels.
11281
- * @since Chrome 31
11282
- */
11295
+ /** The width of the tab in pixels. */
11283
11296
  width?: number | undefined;
11284
- /**
11285
- * Optional. The height of the tab in pixels.
11286
- * @since Chrome 31
11287
- */
11297
+ /** The height of the tab in pixels. */
11288
11298
  height?: number | undefined;
11289
- /**
11290
- * Optional. The session ID used to uniquely identify a Tab obtained from the sessions API.
11291
- * @since Chrome 31
11292
- */
11299
+ /** The session ID used to uniquely identify a tab obtained from the {@link sessions} API. */
11293
11300
  sessionId?: string | undefined;
11294
11301
  /**
11295
11302
  * The ID of the group that the tab belongs to.
@@ -11303,203 +11310,201 @@ export namespace Browser {
11303
11310
  lastAccessed?: number | undefined;
11304
11311
  }
11305
11312
 
11306
- /**
11307
- * Defines how zoom changes in a tab are handled and at what scope.
11308
- * @since Chrome 38
11309
- */
11313
+ /** The tab's loading status. */
11314
+ export enum TabStatus {
11315
+ UNLOADED = "unloaded",
11316
+ LOADING = "loading",
11317
+ COMPLETE = "complete",
11318
+ }
11319
+
11320
+ /** The type of window. */
11321
+ export enum WindowType {
11322
+ NORMAL = "normal",
11323
+ POPUP = "popup",
11324
+ PANEL = "panel",
11325
+ APP = "app",
11326
+ DEVTOOLS = "devtools",
11327
+ }
11328
+
11329
+ /** Defines how zoom changes in a tab are handled and at what scope. */
11310
11330
  export interface ZoomSettings {
11331
+ /** Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to `automatic`. */
11332
+ mode?: `${ZoomSettingsMode}` | undefined;
11333
+ /** 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. */
11334
+ scope?: `${ZoomSettingsScope}` | undefined;
11311
11335
  /**
11312
- * Optional.
11313
- * Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to "automatic".
11314
- * "automatic": Zoom changes are handled automatically by the browser.
11315
- * "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.
11316
- * "disabled": Disables all zooming in the tab. The tab will revert to the default zoom level, and all attempted zoom changes will be ignored.
11317
- */
11318
- mode?: string | undefined;
11319
- /**
11320
- * Optional.
11321
- * 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.
11322
- * "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.
11323
- * "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.
11324
- */
11325
- scope?: string | undefined;
11326
- /**
11327
- * Optional.
11328
- * Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings.
11336
+ * Used to return the default zoom level for the current tab in calls to {@link tabs.getZoomSettings}.
11329
11337
  * @since Chrome 43
11330
11338
  */
11331
11339
  defaultZoomFactor?: number | undefined;
11332
11340
  }
11333
11341
 
11342
+ /**
11343
+ * Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to `automatic`.
11344
+ * @since Chrome 44
11345
+ */
11346
+ export enum ZoomSettingsMode {
11347
+ /** Zoom changes are handled automatically by the browser. */
11348
+ AUTOMATIC = "automatic",
11349
+ /** 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`. */
11350
+ MANUAL = "manual",
11351
+ /** Disables all zooming in the tab. The tab reverts to the default zoom level, and all attempted zoom changes are ignored. */
11352
+ DISABLED = "disabled",
11353
+ }
11354
+
11355
+ /**
11356
+ * 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.
11357
+ * @since Chrome 44
11358
+ */
11359
+ export enum ZoomSettingsScope {
11360
+ /** 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. */
11361
+ PER_ORIGIN = "per-origin",
11362
+ /** 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. */
11363
+ PER_TAB = "per-tab",
11364
+ }
11365
+
11366
+ /**
11367
+ * The maximum number of times that {@link captureVisibleTab} can be called per second. {@link captureVisibleTab} is expensive and should not be called too often.
11368
+ * @since Chrome 92
11369
+ */
11370
+ export const MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND = 2;
11371
+
11372
+ /**
11373
+ * An ID that represents the absence of a browser tab.
11374
+ * @since Chrome 46
11375
+ */
11376
+ export const TAB_ID_NONE = -1;
11377
+
11378
+ /**
11379
+ * An index that represents the absence of a tab index in a tab_strip.
11380
+ * @since Chrome 123
11381
+ */
11382
+ export const TAB_INDEX_NONE = -1;
11383
+
11334
11384
  export interface CreateProperties {
11335
- /** 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. */
11385
+ /** 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. */
11336
11386
  index?: number | undefined;
11337
- /**
11338
- * Optional.
11339
- * 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.
11340
- * @since Chrome 18
11341
- */
11387
+ /** 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. */
11342
11388
  openerTabId?: number | undefined;
11343
- /**
11344
- * Optional.
11345
- * 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.
11346
- */
11389
+ /** 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. */
11347
11390
  url?: string | undefined;
11348
- /**
11349
- * Optional. Whether the tab should be pinned. Defaults to false
11350
- * @since Chrome 9
11351
- */
11391
+ /** Whether the tab should be pinned. Defaults to `false` */
11352
11392
  pinned?: boolean | undefined;
11353
- /** Optional. The window to create the new tab in. Defaults to the current window. */
11393
+ /** The window in which to create the new tab. Defaults to the current window. */
11354
11394
  windowId?: number | undefined;
11355
- /**
11356
- * Optional.
11357
- * 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.
11358
- * @since Chrome 16
11359
- */
11395
+ /** 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`. */
11360
11396
  active?: boolean | undefined;
11361
11397
  /**
11362
- * Optional. Whether the tab should become the selected tab in the window. Defaults to true
11363
- * @deprecated since Chrome 33. Please use active.
11398
+ * Whether the tab should become the selected tab in the window. Defaults to `true`
11399
+ * @deprecated since Chrome 33. Please use {@link CreateProperties.active active}.
11364
11400
  */
11365
11401
  selected?: boolean | undefined;
11366
11402
  }
11367
11403
 
11368
11404
  export interface MoveProperties {
11369
- /** The position to move the window to. -1 will place the tab at the end of the window. */
11405
+ /** The position to move the window to. Use `-1` to place the tab at the end of the window. */
11370
11406
  index: number;
11371
- /** Optional. Defaults to the window the tab is currently in. */
11407
+ /** Defaults to the window the tab is currently in. */
11372
11408
  windowId?: number | undefined;
11373
11409
  }
11374
11410
 
11375
11411
  export interface UpdateProperties {
11376
- /**
11377
- * Optional. Whether the tab should be pinned.
11378
- * @since Chrome 9
11379
- */
11412
+ /** Whether the tab should be pinned. */
11380
11413
  pinned?: boolean | undefined;
11381
- /**
11382
- * Optional. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.
11383
- * @since Chrome 18
11384
- */
11414
+ /** The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab. */
11385
11415
  openerTabId?: number | undefined;
11386
- /** Optional. A URL to navigate the tab to. */
11416
+ /** A URL to navigate the tab to. JavaScript URLs are not supported; use {@link scripting.executeScript} instead. */
11387
11417
  url?: string | undefined;
11388
- /**
11389
- * Optional. Adds or removes the tab from the current selection.
11390
- * @since Chrome 16
11391
- */
11418
+ /** Adds or removes the tab from the current selection. */
11392
11419
  highlighted?: boolean | undefined;
11393
- /**
11394
- * Optional. Whether the tab should be active. Does not affect whether the window is focused (see windows.update).
11395
- * @since Chrome 16
11396
- */
11420
+ /** Whether the tab should be active. Does not affect whether the window is focused (see {@link windows.update}).*/
11397
11421
  active?: boolean | undefined;
11398
11422
  /**
11399
- * Optional. Whether the tab should be selected.
11400
- * @deprecated since Chrome 33. Please use highlighted.
11423
+ * Whether the tab should be selected.
11424
+ * @deprecated since Chrome 33. Please use {@link highlighted}.
11401
11425
  */
11402
11426
  selected?: boolean | undefined;
11403
11427
  /**
11404
- * Optional. Whether the tab should be muted.
11428
+ * Whether the tab should be muted.
11405
11429
  * @since Chrome 45
11406
11430
  */
11407
11431
  muted?: boolean | undefined;
11408
11432
  /**
11409
- * Optional. Whether the tab should be discarded automatically by the browser when resources are low.
11433
+ * Whether the tab should be discarded automatically by the browser when resources are low.
11410
11434
  * @since Chrome 54
11411
11435
  */
11412
11436
  autoDiscardable?: boolean | undefined;
11413
11437
  }
11414
11438
 
11415
11439
  export interface ReloadProperties {
11416
- /** Optional. Whether using any local cache. Default is false. */
11440
+ /** Whether to bypass local caching. Defaults to `false`. */
11417
11441
  bypassCache?: boolean | undefined;
11418
11442
  }
11419
11443
 
11420
11444
  export interface ConnectInfo {
11421
- /** Optional. Will be passed into onConnect for content scripts that are listening for the connection event. */
11445
+ /** Is passed into onConnect for content scripts that are listening for the connection event. */
11422
11446
  name?: string | undefined;
11423
- /**
11424
- * Open a port to a specific frame identified by frameId instead of all frames in the tab.
11425
- * @since Chrome 41
11426
- */
11447
+ /** Open a port to a specific frame identified by `frameId` instead of all frames in the tab. */
11427
11448
  frameId?: number | undefined;
11428
11449
  /**
11429
- * Optional. Open a port to a specific document identified by documentId instead of all frames in the tab.
11450
+ * Open a port to a specific document identified by `documentId` instead of all frames in the tab.
11430
11451
  * @since Chrome 106
11431
11452
  */
11432
11453
  documentId?: string;
11433
11454
  }
11434
11455
 
11435
11456
  export interface MessageSendOptions {
11436
- /** Optional. Send a message to a specific frame identified by frameId instead of all frames in the tab. */
11457
+ /** Send a message to a specific frame identified by `frameId` instead of all frames in the tab. */
11437
11458
  frameId?: number | undefined;
11438
11459
  /**
11439
- * Optional. Send a message to a specific document identified by documentId instead of all frames in the tab.
11460
+ * Send a message to a specific document identified by `documentId` instead of all frames in the tab.
11440
11461
  * @since Chrome 106
11441
11462
  */
11442
11463
  documentId?: string;
11443
11464
  }
11444
11465
 
11445
11466
  export interface GroupOptions {
11446
- /** Optional. Configurations for creating a group. Cannot be used if groupId is already specified. */
11467
+ /** Configurations for creating a group. Cannot be used if groupId is already specified. */
11447
11468
  createProperties?: {
11448
- /** Optional. The window of the new group. Defaults to the current window. */
11469
+ /** The window of the new group. Defaults to the current window. */
11449
11470
  windowId?: number | undefined;
11450
11471
  } | undefined;
11451
- /** Optional. The ID of the group to add the tabs to. If not specified, a new group will be created. */
11472
+ /** The ID of the group to add the tabs to. If not specified, a new group will be created. */
11452
11473
  groupId?: number | undefined;
11453
- /** TOptional. he tab ID or list of tab IDs to add to the specified group. */
11454
- tabIds?: number | number[] | undefined;
11474
+ /** The tab ID or list of tab IDs to add to the specified group. */
11475
+ tabIds?: number | [number, ...number[]] | undefined;
11455
11476
  }
11456
11477
 
11457
11478
  export interface HighlightInfo {
11458
11479
  /** One or more tab indices to highlight. */
11459
11480
  tabs: number | number[];
11460
- /** Optional. The window that contains the tabs. */
11481
+ /** The window that contains the tabs. */
11461
11482
  windowId?: number | undefined;
11462
11483
  }
11463
11484
 
11464
11485
  export interface QueryInfo {
11465
- /**
11466
- * Optional. Whether the tabs have completed loading.
11467
- * One of: "loading", or "complete"
11468
- */
11469
- status?: "loading" | "complete" | undefined;
11470
- /**
11471
- * Optional. Whether the tabs are in the last focused window.
11472
- * @since Chrome 19
11473
- */
11486
+ /** The tab loading status. */
11487
+ status?: `${TabStatus}` | undefined;
11488
+ /** Whether the tabs are in the last focused window. */
11474
11489
  lastFocusedWindow?: boolean | undefined;
11475
- /** Optional. The ID of the parent window, or windows.WINDOW_ID_CURRENT for the current window. */
11490
+ /** The ID of the parent window, or {@link windows.WINDOW_ID_CURRENT} for the current window. */
11476
11491
  windowId?: number | undefined;
11477
- /**
11478
- * Optional. The type of window the tabs are in.
11479
- * One of: "normal", "popup", "panel", "app", or "devtools"
11480
- */
11481
- windowType?: "normal" | "popup" | "panel" | "app" | "devtools" | undefined;
11482
- /** Optional. Whether the tabs are active in their windows. */
11492
+ /** The type of window the tabs are in. */
11493
+ windowType?: `${WindowType}` | undefined;
11494
+ /** Whether the tabs are active in their windows. */
11483
11495
  active?: boolean | undefined;
11484
- /**
11485
- * Optional. The position of the tabs within their windows.
11486
- * @since Chrome 18
11487
- */
11496
+ /** The position of the tabs within their windows. */
11488
11497
  index?: number | undefined;
11489
- /** Match page titles against a pattern. This property is ignored if the extension does not have the `tabs` permission or host permissions for the page. */
11498
+ /** 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. */
11490
11499
  title?: string | undefined;
11491
- /** Match tabs against one or more URL patterns. Fragment identifiers are not matched. This property is ignored if the extension does not have the `tabs` permission or host permissions for the page. */
11500
+ /** 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. */
11492
11501
  url?: string | string[] | undefined;
11493
- /**
11494
- * Optional. Whether the tabs are in the current window.
11495
- * @since Chrome 19
11496
- */
11502
+ /** Whether the tabs are in the current window. */
11497
11503
  currentWindow?: boolean | undefined;
11498
- /** Optional. Whether the tabs are highlighted. */
11504
+ /** Whether the tabs are highlighted. */
11499
11505
  highlighted?: boolean | undefined;
11500
11506
  /**
11501
- * Optional.
11502
- * 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.
11507
+ * 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.
11503
11508
  * @since Chrome 54
11504
11509
  */
11505
11510
  discarded?: boolean | undefined;
@@ -11507,866 +11512,560 @@ export namespace Browser {
11507
11512
  * 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.
11508
11513
  * @since Chrome 132
11509
11514
  */
11510
- frozen?: boolean;
11515
+ frozen?: boolean | undefined;
11511
11516
  /**
11512
- * Optional.
11513
11517
  * Whether the tabs can be discarded automatically by the browser when resources are low.
11514
11518
  * @since Chrome 54
11515
11519
  */
11516
11520
  autoDiscardable?: boolean | undefined;
11517
- /** Optional. Whether the tabs are pinned. */
11521
+ /** Whether the tabs are pinned. */
11518
11522
  pinned?: boolean | undefined;
11519
11523
  /**
11520
- * Optional. Whether the tabs are audible.
11524
+ * Whether the tabs are audible.
11521
11525
  * @since Chrome 45
11522
11526
  */
11523
11527
  audible?: boolean | undefined;
11524
11528
  /**
11525
- * Optional. Whether the tabs are muted.
11529
+ * Whether the tabs are muted.
11526
11530
  * @since Chrome 45
11527
11531
  */
11528
11532
  muted?: boolean | undefined;
11529
11533
  /**
11530
- * Optional. The ID of the group that the tabs are in, or Browser.tabGroups.TAB_GROUP_ID_NONE for ungrouped tabs.
11534
+ * The ID of the group that the tabs are in, or {@link Browser.tabGroups.TAB_GROUP_ID_NONE} for ungrouped tabs.
11531
11535
  * @since Chrome 88
11532
11536
  */
11533
11537
  groupId?: number | undefined;
11534
11538
  }
11535
11539
 
11536
- export interface TabHighlightInfo {
11537
- windowId: number;
11540
+ export interface OnHighlightedInfo {
11541
+ /** All highlighted tabs in the window. */
11538
11542
  tabIds: number[];
11539
- }
11540
-
11541
- export interface TabRemoveInfo {
11542
- /**
11543
- * The window whose tab is closed.
11544
- * @since Chrome 25
11545
- */
11543
+ /** The window whose tabs changed. */
11546
11544
  windowId: number;
11547
- /** True when the tab is being closed because its window is being closed. */
11548
- isWindowClosing: boolean;
11549
11545
  }
11550
11546
 
11551
- export interface TabAttachInfo {
11552
- newPosition: number;
11553
- newWindowId: number;
11547
+ export interface OnRemovedInfo {
11548
+ /** True when the tab was closed because its parent window was closed. */
11549
+ isWindowClosing: boolean;
11550
+ /** The window whose tab is closed */
11551
+ windowId: number;
11554
11552
  }
11555
11553
 
11556
- export interface TabChangeInfo {
11557
- /** Optional. The status of the tab. Can be either loading or complete. */
11558
- status?: string | undefined;
11554
+ export interface OnUpdatedInfo {
11555
+ /** The tab's new audible state. */
11556
+ audible?: boolean;
11559
11557
  /**
11560
- * The tab's new pinned state.
11561
- * @since Chrome 9
11558
+ * The tab's new auto-discardable state.
11559
+ * @since Chrome 54
11562
11560
  */
11563
- pinned?: boolean | undefined;
11564
- /** Optional. The tab's URL if it has changed. */
11565
- url?: string | undefined;
11566
- /**
11567
- * The tab's new audible state.
11568
- * @since Chrome 45
11569
- */
11570
- audible?: boolean | undefined;
11561
+ autoDiscardable?: boolean;
11571
11562
  /**
11572
11563
  * The tab's new discarded state.
11573
11564
  * @since Chrome 54
11574
11565
  */
11575
- discarded?: boolean | undefined;
11566
+ discarded?: boolean;
11567
+ /** The tab's new favicon URL. */
11568
+ favIconUrl?: string;
11576
11569
  /**
11577
- * The tab's new auto-discardable
11578
- * @since Chrome 54
11570
+ * The tab's new frozen state.
11571
+ * @since Chrome 132
11579
11572
  */
11580
- autoDiscardable?: boolean | undefined;
11573
+ frozen?: boolean;
11581
11574
  /**
11582
11575
  * The tab's new group.
11583
11576
  * @since Chrome 88
11584
11577
  */
11585
- groupId?: number | undefined;
11578
+ groupId?: number;
11586
11579
  /**
11587
11580
  * The tab's new muted state and the reason for the change.
11588
11581
  * @since Chrome 46
11589
11582
  */
11590
- mutedInfo?: MutedInfo | undefined;
11591
- /**
11592
- * The tab's new favicon URL.
11593
- * @since Chrome 27
11594
- */
11595
- favIconUrl?: string | undefined;
11596
- /**
11597
- * The tab's new frozen state.
11598
- * @since Chrome 132
11599
- */
11600
- frozen?: boolean;
11583
+ mutedInfo?: MutedInfo;
11584
+ /** The tab's new pinned state. */
11585
+ pinned?: boolean;
11586
+ /** The tab's loading status. */
11587
+ status?: `${TabStatus}`;
11601
11588
  /**
11602
11589
  * The tab's new title.
11603
11590
  * @since Chrome 48
11604
11591
  */
11605
- title?: string | undefined;
11592
+ title?: string;
11593
+ /** The tab's URL if it has changed. */
11594
+ url?: string;
11606
11595
  }
11607
11596
 
11608
- export interface TabMoveInfo {
11597
+ export interface OnAttachedInfo {
11598
+ newPosition: number;
11599
+ newWindowId: number;
11600
+ }
11601
+
11602
+ export interface OnMovedInfo {
11603
+ fromIndex: number;
11609
11604
  toIndex: number;
11610
11605
  windowId: number;
11611
- fromIndex: number;
11612
11606
  }
11613
11607
 
11614
- export interface TabDetachInfo {
11615
- oldWindowId: number;
11608
+ export interface OnDetachedInfo {
11616
11609
  oldPosition: number;
11610
+ oldWindowId: number;
11617
11611
  }
11618
11612
 
11619
- export interface TabActiveInfo {
11613
+ export interface OnActivatedInfo {
11620
11614
  /** The ID of the tab that has become active. */
11621
11615
  tabId: number;
11622
11616
  /** The ID of the window the active tab changed inside of. */
11623
11617
  windowId: number;
11624
11618
  }
11625
11619
 
11626
- export interface TabWindowInfo {
11627
- /** The ID of the window of where the tab is located. */
11620
+ export interface OnSelectionChangedInfo {
11621
+ /** The ID of the window the selected tab changed inside of. */
11628
11622
  windowId: number;
11629
11623
  }
11630
11624
 
11631
- export interface ZoomChangeInfo {
11632
- tabId: number;
11633
- oldZoomFactor: number;
11634
- newZoomFactor: number;
11635
- zoomSettings: ZoomSettings;
11625
+ export interface OnActiveChangedInfo {
11626
+ /** The ID of the window the selected tab changed inside of. */
11627
+ windowId: number;
11636
11628
  }
11637
11629
 
11638
- export interface TabHighlightedEvent extends Browser.events.Event<(highlightInfo: TabHighlightInfo) => void> {}
11639
-
11640
- export interface TabRemovedEvent
11641
- extends Browser.events.Event<(tabId: number, removeInfo: TabRemoveInfo) => void>
11642
- {}
11643
-
11644
- export interface TabUpdatedEvent
11645
- extends Browser.events.Event<(tabId: number, changeInfo: TabChangeInfo, tab: Tab) => void>
11646
- {}
11647
-
11648
- export interface TabAttachedEvent
11649
- extends Browser.events.Event<(tabId: number, attachInfo: TabAttachInfo) => void>
11650
- {}
11651
-
11652
- export interface TabMovedEvent extends Browser.events.Event<(tabId: number, moveInfo: TabMoveInfo) => void> {}
11653
-
11654
- export interface TabDetachedEvent
11655
- extends Browser.events.Event<(tabId: number, detachInfo: TabDetachInfo) => void>
11656
- {}
11657
-
11658
- export interface TabCreatedEvent extends Browser.events.Event<(tab: Tab) => void> {}
11659
-
11660
- export interface TabActivatedEvent extends Browser.events.Event<(activeInfo: TabActiveInfo) => void> {}
11661
-
11662
- export interface TabReplacedEvent
11663
- extends Browser.events.Event<(addedTabId: number, removedTabId: number) => void>
11664
- {}
11665
-
11666
- export interface TabSelectedEvent
11667
- extends Browser.events.Event<(tabId: number, selectInfo: TabWindowInfo) => void>
11668
- {}
11630
+ export interface OnHighlightChangedInfo {
11631
+ /** All highlighted tabs in the window. */
11632
+ tabIds: number[];
11633
+ /** The window whose tabs changed. */
11634
+ windowId: number;
11635
+ }
11669
11636
 
11670
- export interface TabZoomChangeEvent extends Browser.events.Event<(ZoomChangeInfo: ZoomChangeInfo) => void> {}
11637
+ export interface OnZoomChangeInfo {
11638
+ newZoomFactor: number;
11639
+ oldZoomFactor: number;
11640
+ tabId: number;
11641
+ zoomSettings: ZoomSettings;
11642
+ }
11671
11643
 
11672
11644
  /**
11673
11645
  * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11674
- * @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.
11675
- * @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.
11676
- */
11677
- export function executeScript(details: extensionTypes.InjectDetails): Promise<any[]>;
11678
- /**
11679
- * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11680
- * @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.
11681
- * @param callback Optional. Called after all the JavaScript has been executed.
11682
- * Parameter result: The result of the script in every injected frame.
11683
- */
11684
- export function executeScript(details: extensionTypes.InjectDetails, callback?: (result: any[]) => void): void;
11685
- /**
11686
- * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11687
- * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window.
11688
- * @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.
11689
- * @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.
11690
- */
11691
- export function executeScript(tabId: number, details: extensionTypes.InjectDetails): Promise<any[]>;
11692
- /**
11693
- * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
11694
- * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window.
11695
- * @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.
11696
- * @param callback Optional. Called after all the JavaScript has been executed.
11697
- * Parameter result: The result of the script in every injected frame.
11646
+ *
11647
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11648
+ *
11649
+ * MV2 only
11650
+ * @param tabId The ID of the tab in which to run the script; defaults to the active tab of the current window.
11651
+ * @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
11652
+ * @deprecated since Chrome 99. Replaced by {@link scripting.executeScript} in Manifest V3.
11698
11653
  */
11654
+ export function executeScript(details: extensionTypes.InjectDetails): Promise<any[] | undefined>;
11699
11655
  export function executeScript(
11700
- tabId: number,
11656
+ tabId: number | undefined,
11701
11657
  details: extensionTypes.InjectDetails,
11702
- callback?: (result: any[]) => void,
11658
+ ): Promise<any[] | undefined>;
11659
+ export function executeScript(details: extensionTypes.InjectDetails, callback: (result?: any[]) => void): void;
11660
+ export function executeScript(
11661
+ tabId: number | undefined,
11662
+ details: extensionTypes.InjectDetails,
11663
+ callback: (result?: any[]) => void,
11703
11664
  ): void;
11704
- /** Retrieves details about the specified tab. */
11705
- export function get(tabId: number, callback: (tab: Tab) => void): void;
11665
+
11706
11666
  /**
11707
- * Retrieves details about the specified tab.
11708
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
11667
+ * Retrieves details about the specified tab
11668
+ *
11669
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11709
11670
  */
11710
11671
  export function get(tabId: number): Promise<Tab>;
11672
+ export function get(tabId: number, callback: (tab: Tab) => void): void;
11673
+
11711
11674
  /**
11712
11675
  * Gets details about all tabs in the specified window.
11713
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11714
- */
11715
- export function getAllInWindow(callback: (tab: Tab) => void): void;
11716
- /**
11717
- * Gets details about all tabs in the specified window.
11718
- * @return The `getAllInWindow` method provides its result via callback or returned as a `Promise` (MV3 only).
11719
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11720
- */
11721
- export function getAllInWindow(): Promise<Tab>;
11722
- /**
11723
- * Gets details about all tabs in the specified window.
11724
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11725
- * @param windowId Optional. Defaults to the current window.
11726
- */
11727
- export function getAllInWindow(windowId: number, callback: (tab: Tab) => void): void;
11728
- /**
11729
- * Gets details about all tabs in the specified window.
11730
- * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}.
11731
- * @param windowId Optional. Defaults to the current window.
11732
- * @return The `getAllInWindow` method provides its result via callback or returned as a `Promise` (MV3 only).
11676
+ *
11677
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11678
+ *
11679
+ * MV2 only
11680
+ * @deprecated Please use {@link tabs.query} `{windowId: windowId}`.
11733
11681
  */
11734
- export function getAllInWindow(windowId: number): Promise<Tab>;
11735
- /** 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). */
11736
- export function getCurrent(callback: (tab?: Tab) => void): void;
11682
+ export function getAllInWindow(windowId?: number): Promise<Tab[]>;
11683
+ export function getAllInWindow(callback: (tabs: Tab[]) => void): void;
11684
+ export function getAllInWindow(windowId: number | undefined, callback: (tabs: Tab[]) => void): void;
11685
+
11737
11686
  /**
11738
- * 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).
11739
- * @return The `getCurrent` method provides its result via callback or returned as a `Promise` (MV3 only).
11687
+ * 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).
11688
+ *
11689
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11740
11690
  */
11741
11691
  export function getCurrent(): Promise<Tab | undefined>;
11692
+ export function getCurrent(callback: (tab?: Tab) => void): void;
11693
+
11742
11694
  /**
11743
11695
  * Gets the tab that is selected in the specified window.
11744
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11696
+ *
11697
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11698
+ *
11699
+ * MV2 only
11700
+ * @param windowId Defaults to the current window.
11701
+ * @deprecated Please use {@link tabs.query} `{active: true}`.
11745
11702
  */
11703
+ export function getSelected(windowId?: number): Promise<Tab>;
11746
11704
  export function getSelected(callback: (tab: Tab) => void): void;
11747
- /**
11748
- * Gets the tab that is selected in the specified window.
11749
- * @return The `getSelected` method provides its result via callback or returned as a `Promise` (MV3 only).
11750
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11751
- */
11752
- export function getSelected(): Promise<Tab>;
11753
- /**
11754
- * Gets the tab that is selected in the specified window.
11755
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11756
- * @param windowId Optional. Defaults to the current window.
11757
- */
11758
- export function getSelected(windowId: number, callback: (tab: Tab) => void): void;
11759
- /**
11760
- * Gets the tab that is selected in the specified window.
11761
- * @deprecated since Chrome 33. Please use tabs.query {active: true}.
11762
- * @param windowId Optional. Defaults to the current window.
11763
- * @return The `getSelected` method provides its result via callback or returned as a `Promise` (MV3 only).
11764
- */
11765
- export function getSelected(windowId: number): Promise<Tab>;
11705
+ export function getSelected(windowId: number | undefined, callback: (tab: Tab) => void): void;
11706
+
11766
11707
  /**
11767
11708
  * Creates a new tab.
11768
- * @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.
11709
+ *
11710
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11769
11711
  */
11770
11712
  export function create(createProperties: CreateProperties): Promise<Tab>;
11771
- /**
11772
- * Creates a new tab.
11773
- * @param callback Optional.
11774
- * Parameter tab: Details about the created tab. Will contain the ID of the new tab.
11775
- */
11776
11713
  export function create(createProperties: CreateProperties, callback: (tab: Tab) => void): void;
11714
+
11777
11715
  /**
11778
11716
  * 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.
11779
- * @param tabId The tab to move.
11780
- * @return The `move` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the moved tab.
11717
+ * @param tabId The tab ID to move.
11718
+ * @param tabIds List of tab IDs to move.
11719
+ *
11720
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11781
11721
  */
11782
11722
  export function move(tabId: number, moveProperties: MoveProperties): Promise<Tab>;
11783
- /**
11784
- * 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.
11785
- * @param tabId The tab to move.
11786
- * @param callback Optional.
11787
- * Parameter tab: Details about the moved tab.
11788
- */
11789
- export function move(tabId: number, moveProperties: MoveProperties, callback: (tab: Tab) => void): void;
11790
- /**
11791
- * 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.
11792
- * @param tabIds The tabs to move.
11793
- * @return The `move` method provides its result via callback or returned as a `Promise` (MV3 only). Details about the moved tabs.
11794
- */
11795
11723
  export function move(tabIds: number[], moveProperties: MoveProperties): Promise<Tab[]>;
11796
- /**
11797
- * 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.
11798
- * @param tabIds The tabs to move.
11799
- * @param callback Optional.
11800
- * Parameter tabs: Details about the moved tabs.
11801
- */
11724
+ export function move(tabId: number, moveProperties: MoveProperties, callback: (tab: Tab) => void): void;
11802
11725
  export function move(tabIds: number[], moveProperties: MoveProperties, callback: (tabs: Tab[]) => void): void;
11726
+
11803
11727
  /**
11804
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11805
- * @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..
11728
+ * Modifies the properties of a tab. Properties that are not specified in `updateProperties` are not modified.
11729
+ *
11730
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11731
+ * @param tabId Defaults to the selected tab of the current window.
11806
11732
  */
11807
11733
  export function update(updateProperties: UpdateProperties): Promise<Tab | undefined>;
11808
- /**
11809
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11810
- * @param callback Optional.
11811
- * 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..
11812
- */
11734
+ export function update(tabId: number | undefined, updateProperties: UpdateProperties): Promise<Tab | undefined>;
11813
11735
  export function update(updateProperties: UpdateProperties, callback: (tab?: Tab) => void): void;
11736
+ export function update(
11737
+ tabId: number | undefined,
11738
+ updateProperties: UpdateProperties,
11739
+ callback: (tab?: Tab) => void,
11740
+ ): void;
11741
+
11814
11742
  /**
11815
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11816
- * @param tabId Defaults to the selected tab of the current window.
11817
- * @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..
11818
- */
11819
- export function update(tabId: number, updateProperties: UpdateProperties): Promise<Tab | undefined>;
11820
- /**
11821
- * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
11822
- * @param tabId Defaults to the selected tab of the current window.
11823
- * @param callback Optional.
11824
- * 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..
11825
- */
11826
- export function update(tabId: number, updateProperties: UpdateProperties, callback: (tab?: Tab) => void): void;
11827
- /**
11828
- * Closes a tab.
11829
- * @param tabId The tab to close.
11830
- * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11743
+ * Closes one or more tabs.
11744
+ *
11745
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11746
+ * @param tabId The tab ID to close.
11747
+ * @param tabIds List of tab IDs to close.
11831
11748
  */
11832
11749
  export function remove(tabId: number): Promise<void>;
11833
- /**
11834
- * Closes a tab.
11835
- * @param tabId The tab to close.
11836
- */
11837
- export function remove(tabId: number, callback: () => void): void;
11838
- /**
11839
- * Closes several tabs.
11840
- * @param tabIds The list of tabs to close.
11841
- * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11842
- */
11843
11750
  export function remove(tabIds: number[]): Promise<void>;
11844
- /**
11845
- * Closes several tabs.
11846
- * @param tabIds The list of tabs to close.
11847
- */
11751
+ export function remove(tabId: number, callback: () => void): void;
11848
11752
  export function remove(tabIds: number[], callback: () => void): void;
11753
+
11849
11754
  /**
11850
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11851
- * @param callback
11852
- * 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.
11853
- */
11854
- export function captureVisibleTab(callback: (dataUrl: string) => void): void;
11855
- /**
11856
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11857
- * @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.
11755
+ * 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.
11756
+ *
11757
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11758
+ * @param windowId The target window. Defaults to the current window.
11858
11759
  */
11859
11760
  export function captureVisibleTab(): Promise<string>;
11860
- /**
11861
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11862
- * @param windowId Optional. The target window. Defaults to the current window.
11863
- * @param callback
11864
- * 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.
11865
- */
11866
- export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void;
11867
- /**
11868
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11869
- * @param windowId Optional. The target window. Defaults to the current window.
11870
- * @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.
11871
- */
11872
11761
  export function captureVisibleTab(windowId: number): Promise<string>;
11873
- /**
11874
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11875
- * @param options Optional. Details about the format and quality of an image.
11876
- * @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.
11877
- */
11878
11762
  export function captureVisibleTab(options: extensionTypes.ImageDetails): Promise<string>;
11879
- /**
11880
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11881
- * @param options Optional. Details about the format and quality of an image.
11882
- * @param callback
11883
- * 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.
11884
- */
11763
+ export function captureVisibleTab(windowId: number, options: extensionTypes.ImageDetails): Promise<string>;
11764
+ export function captureVisibleTab(callback: (dataUrl: string) => void): void;
11765
+ export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void;
11885
11766
  export function captureVisibleTab(
11886
11767
  options: extensionTypes.ImageDetails,
11887
11768
  callback: (dataUrl: string) => void,
11888
11769
  ): void;
11889
- /**
11890
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11891
- * @param windowId Optional. The target window. Defaults to the current window.
11892
- * @param options Optional. Details about the format and quality of an image.
11893
- * @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.
11894
- */
11895
- export function captureVisibleTab(
11896
- windowId: number,
11897
- options: extensionTypes.ImageDetails,
11898
- ): Promise<string>;
11899
- /**
11900
- * Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
11901
- * @param windowId Optional. The target window. Defaults to the current window.
11902
- * @param options Optional. Details about the format and quality of an image.
11903
- * @param callback
11904
- * 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.
11905
- */
11906
11770
  export function captureVisibleTab(
11907
11771
  windowId: number,
11908
11772
  options: extensionTypes.ImageDetails,
11909
11773
  callback: (dataUrl: string) => void,
11910
11774
  ): void;
11775
+
11911
11776
  /**
11912
11777
  * Reload a tab.
11913
- * @since Chrome 16
11778
+ *
11779
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11914
11780
  * @param tabId The ID of the tab to reload; defaults to the selected tab of the current window.
11915
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11916
11781
  */
11782
+ export function reload(): Promise<void>;
11917
11783
  export function reload(tabId: number): Promise<void>;
11918
- /**
11919
- * Reload a tab.
11920
- * @since Chrome 16
11921
- * @param tabId The ID of the tab to reload; defaults to the selected tab of the current window.
11922
- */
11923
- export function reload(tabId: number, callback?: () => void): void;
11924
- /**
11925
- * Reload the selected tab of the current window.
11926
- * @since Chrome 16
11927
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11928
- */
11929
11784
  export function reload(reloadProperties: ReloadProperties): Promise<void>;
11930
- /**
11931
- * Reload the selected tab of the current window.
11932
- * @since Chrome 16
11933
- */
11934
- export function reload(reloadProperties: ReloadProperties, callback: () => void): void;
11935
- /**
11936
- * Reload the selected tab of the current window.
11937
- * @since Chrome 16
11938
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11939
- */
11940
11785
  export function reload(tabId: number, reloadProperties: ReloadProperties): Promise<void>;
11941
- /**
11942
- * Reload the selected tab of the current window.
11943
- * @since Chrome 16
11944
- */
11945
- export function reload(tabId: number, reloadProperties: ReloadProperties, callback: () => void): void;
11946
- /**
11947
- * Reload the selected tab of the current window.
11948
- * @since Chrome 16
11949
- * @return The `reload` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11950
- */
11951
- export function reload(): Promise<void>;
11952
- /**
11953
- * Reload the selected tab of the current window.
11954
- * @since Chrome 16
11955
- */
11956
11786
  export function reload(callback: () => void): void;
11787
+ export function reload(tabId: number | undefined, callback: () => void): void;
11788
+ export function reload(reloadProperties: ReloadProperties | undefined, callback: () => void): void;
11789
+ export function reload(
11790
+ tabId: number | undefined,
11791
+ reloadProperties: ReloadProperties | undefined,
11792
+ callback: () => void,
11793
+ ): void;
11794
+
11957
11795
  /**
11958
11796
  * Duplicates a tab.
11959
- * @since Chrome 23
11960
- * @param tabId The ID of the tab which is to be duplicated.
11961
- * @return The `duplicate` method provides its result via callback or returned as a `Promise` (MV3 only).
11797
+ *
11798
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11799
+ * @param tabId The ID of the tab to duplicate.
11962
11800
  */
11963
11801
  export function duplicate(tabId: number): Promise<Tab | undefined>;
11964
- /**
11965
- * Duplicates a tab.
11966
- * @since Chrome 23
11967
- * @param tabId The ID of the tab which is to be duplicated.
11968
- * @param callback Optional.
11969
- * 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.
11970
- */
11971
11802
  export function duplicate(tabId: number, callback: (tab?: Tab) => void): void;
11803
+
11972
11804
  /**
11973
- * 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.
11974
- * @since Chrome 20
11805
+ * 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.
11806
+ *
11807
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
11975
11808
  */
11976
11809
  export function sendMessage<M = any, R = any>(
11977
11810
  tabId: number,
11978
11811
  message: M,
11979
- responseCallback: (response: R) => void,
11980
- ): void;
11981
- /**
11982
- * 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.
11983
- * @since Chrome 41
11984
- * @param responseCallback Optional.
11985
- * 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.
11986
- */
11812
+ options?: MessageSendOptions,
11813
+ ): Promise<R>;
11987
11814
  export function sendMessage<M = any, R = any>(
11988
11815
  tabId: number,
11989
11816
  message: M,
11990
- options: MessageSendOptions,
11991
- responseCallback: (response: R) => void,
11817
+ /** @since Chrome 99 */
11818
+ callback: (response: R) => void,
11992
11819
  ): void;
11993
- /**
11994
- * 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.
11995
- * @since Chrome 99
11996
- */
11997
- export function sendMessage<M = any, R = any>(tabId: number, message: M): Promise<R>;
11998
- /**
11999
- * 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.
12000
- * @since Chrome 99
12001
- */
12002
11820
  export function sendMessage<M = any, R = any>(
12003
11821
  tabId: number,
12004
11822
  message: M,
12005
- options: MessageSendOptions,
12006
- ): Promise<R>;
11823
+ options: MessageSendOptions | undefined,
11824
+ /** @since Chrome 99 */
11825
+ callback: (response: R) => void,
11826
+ ): void;
11827
+
12007
11828
  /**
12008
- * 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.
12009
- * @deprecated since Chrome 33. Please use runtime.sendMessage.
12010
- * @param responseCallback Optional.
12011
- * 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.
11829
+ * 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.
11830
+ *
11831
+ * MV2 only
11832
+ * @deprecated Please use {@link runtime.sendMessage}.
12012
11833
  */
12013
11834
  export function sendRequest<Request = any, Response = any>(
12014
11835
  tabId: number,
12015
11836
  request: Request,
12016
- responseCallback?: (response: Response) => void,
11837
+ ): Promise<Response>;
11838
+ export function sendRequest<Request = any, Response = any>(
11839
+ tabId: number,
11840
+ request: Request,
11841
+ /** @since Chrome 99 */
11842
+ callback?: (response: Response) => void,
12017
11843
  ): void;
12018
- /** 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. */
12019
- export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port;
11844
+
12020
11845
  /**
12021
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12022
- * @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.
12023
- * @return The `insertCSS` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11846
+ * 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.
11847
+ * @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.
12024
11848
  */
12025
- export function insertCSS(details: extensionTypes.InjectDetails): Promise<void>;
11849
+ export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port;
11850
+
12026
11851
  /**
12027
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12028
- * @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.
12029
- * @param callback Optional. Called when all the CSS has been inserted.
11852
+ * 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.
11853
+ *
11854
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11855
+ *
11856
+ * MV2 only
11857
+ * @param tabId The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
11858
+ * @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.
11859
+ * @deprecated since Chrome 99. Replaced by {@link scripting.insertCSS} in Manifest V3.
12030
11860
  */
11861
+ export function insertCSS(details: extensionTypes.InjectDetails): Promise<void>;
11862
+ export function insertCSS(tabId: number | undefined, details: extensionTypes.InjectDetails): Promise<void>;
12031
11863
  export function insertCSS(details: extensionTypes.InjectDetails, callback: () => void): void;
12032
- /**
12033
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12034
- * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
12035
- * @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.
12036
- * @return The `insertCSS` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12037
- */
12038
- export function insertCSS(tabId: number, details: extensionTypes.InjectDetails): Promise<void>;
12039
- /**
12040
- * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
12041
- * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
12042
- * @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.
12043
- * @param callback Optional. Called when all the CSS has been inserted.
12044
- */
11864
+ export function insertCSS(tabId: number | undefined, details: extensionTypes.InjectDetails): Promise<void>;
12045
11865
  export function insertCSS(tabId: number, details: extensionTypes.InjectDetails, callback: () => void): void;
11866
+
12046
11867
  /**
12047
- * Highlights the given tabs.
12048
- * @since Chrome 16
12049
- * @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.
12050
- */
12051
- export function highlight(highlightInfo: HighlightInfo): Promise<Browser.windows.Window>;
12052
- /**
12053
- * Highlights the given tabs.
12054
- * @since Chrome 16
12055
- * @param callback Optional.
12056
- * Parameter window: Contains details about the window whose tabs were highlighted.
12057
- */
12058
- export function highlight(
12059
- highlightInfo: HighlightInfo,
12060
- callback: (window: Browser.windows.Window) => void,
12061
- ): void;
12062
- /**
12063
- * Gets all tabs that have the specified properties, or all tabs if no properties are specified.
12064
- * @since Chrome 16
12065
- */
12066
- export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void;
12067
- /**
12068
- * Gets all tabs that have the specified properties, or all tabs if no properties are specified.
12069
- * @since Chrome 16
12070
- * @return The `query` method provides its result via callback or returned as a `Promise` (MV3 only).
11868
+ * Highlights the given tabs and focuses on the first of group. Will appear to do nothing if the specified tab is currently active.
11869
+ *
11870
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
12071
11871
  */
11872
+ export function highlight(highlightInfo: HighlightInfo): Promise<windows.Window>;
11873
+ export function highlight(highlightInfo: HighlightInfo, callback: (window: windows.Window) => void): void;
11874
+
11875
+ /** Gets all tabs that have the specified properties, or all tabs if no properties are specified. */
12072
11876
  export function query(queryInfo: QueryInfo): Promise<Tab[]>;
11877
+ export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void;
11878
+
12073
11879
  /**
12074
11880
  * Detects the primary language of the content in a tab.
12075
- * @param callback
12076
- * 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.
11881
+ *
11882
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11883
+ * @param tabId The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12077
11884
  */
11885
+ export function detectLanguage(tabId?: number): Promise<string>;
12078
11886
  export function detectLanguage(callback: (language: string) => void): void;
12079
- /**
12080
- * Detects the primary language of the content in a tab.
12081
- * @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.
12082
- */
12083
- export function detectLanguage(): Promise<string>;
12084
- /**
12085
- * Detects the primary language of the content in a tab.
12086
- * @param tabId Optional. Defaults to the active tab of the current window.
12087
- * @param callback
12088
- * 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.
12089
- */
12090
- export function detectLanguage(tabId: number, callback: (language: string) => void): void;
12091
- /**
12092
- * Detects the primary language of the content in a tab.
12093
- * @param tabId Optional. Defaults to the active tab of the current window.
12094
- * @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.
12095
- */
12096
- export function detectLanguage(tabId: number): Promise<string>;
11887
+ export function detectLanguage(tabId: number | undefined, callback: (language: string) => void): void;
11888
+
12097
11889
  /**
12098
11890
  * Zooms a specified tab.
12099
- * @since Chrome 42
12100
- * @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.
12101
- * @return The `setZoom` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
11891
+ *
11892
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11893
+ * @param tabId The ID of the tab to zoom; defaults to the active tab of the current window.
11894
+ * @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.
12102
11895
  */
12103
11896
  export function setZoom(zoomFactor: number): Promise<void>;
12104
- /**
12105
- * Zooms a specified tab.
12106
- * @since Chrome 42
12107
- * @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.
12108
- * @param callback Optional. Called after the zoom factor has been changed.
12109
- */
11897
+ export function setZoom(tabId: number | undefined, zoomFactor: number): Promise<void>;
12110
11898
  export function setZoom(zoomFactor: number, callback: () => void): void;
12111
- /**
12112
- * Zooms a specified tab.
12113
- * @since Chrome 42
12114
- * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window.
12115
- * @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.
12116
- * @return The `setZoom` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12117
- */
12118
- export function setZoom(tabId: number, zoomFactor: number): Promise<void>;
12119
- /**
12120
- * Zooms a specified tab.
12121
- * @since Chrome 42
12122
- * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window.
12123
- * @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.
12124
- * @param callback Optional. Called after the zoom factor has been changed.
12125
- */
12126
- export function setZoom(tabId: number, zoomFactor: number, callback: () => void): void;
11899
+ export function setZoom(tabId: number | undefined, zoomFactor: number, callback: () => void): void;
11900
+
12127
11901
  /**
12128
11902
  * Gets the current zoom factor of a specified tab.
12129
- * @since Chrome 42
12130
- * @param callback Called with the tab's current zoom factor after it has been fetched.
12131
- * Parameter zoomFactor: The tab's current zoom factor.
11903
+ *
11904
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11905
+ * @param tabId The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12132
11906
  */
11907
+ export function getZoom(tabId?: number): Promise<number>;
12133
11908
  export function getZoom(callback: (zoomFactor: number) => void): void;
12134
- /**
12135
- * Gets the current zoom factor of a specified tab.
12136
- * @since Chrome 42
12137
- * @return The `getZoom` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom factor.
12138
- */
12139
- export function getZoom(): Promise<number>;
12140
- /**
12141
- * Gets the current zoom factor of a specified tab.
12142
- * @since Chrome 42
12143
- * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12144
- * @param callback Called with the tab's current zoom factor after it has been fetched.
12145
- * Parameter zoomFactor: The tab's current zoom factor.
12146
- */
12147
- export function getZoom(tabId: number, callback: (zoomFactor: number) => void): void;
12148
- /**
12149
- * Gets the current zoom factor of a specified tab.
12150
- * @since Chrome 42
12151
- * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
12152
- * @return The `getZoom` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom factor.
12153
- */
12154
- export function getZoom(tabId: number): Promise<number>;
11909
+ export function getZoom(tabId: number | undefined, callback: (zoomFactor: number) => void): void;
11910
+
12155
11911
  /**
12156
11912
  * 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.
12157
- * @since Chrome 42
11913
+ *
11914
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11915
+ * @param tabId The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12158
11916
  * @param zoomSettings Defines how zoom changes are handled and at what scope.
12159
- * @return The `setZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12160
11917
  */
12161
11918
  export function setZoomSettings(zoomSettings: ZoomSettings): Promise<void>;
12162
- /**
12163
- * 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.
12164
- * @since Chrome 42
12165
- * @param zoomSettings Defines how zoom changes are handled and at what scope.
12166
- * @param callback Optional. Called after the zoom settings have been changed.
12167
- */
11919
+ export function setZoomSettings(tabId: number | undefined, zoomSettings: ZoomSettings): Promise<void>;
12168
11920
  export function setZoomSettings(zoomSettings: ZoomSettings, callback: () => void): void;
12169
- /**
12170
- * 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.
12171
- * @since Chrome 42
12172
- * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12173
- * @param zoomSettings Defines how zoom changes are handled and at what scope.
12174
- * @return The `setZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12175
- */
12176
- export function setZoomSettings(tabId: number, zoomSettings: ZoomSettings): Promise<void>;
12177
- /**
12178
- * 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.
12179
- * @since Chrome 42
12180
- * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
12181
- * @param zoomSettings Defines how zoom changes are handled and at what scope.
12182
- * @param callback Optional. Called after the zoom settings have been changed.
12183
- */
12184
- export function setZoomSettings(tabId: number, zoomSettings: ZoomSettings, callback: () => void): void;
11921
+ export function setZoomSettings(
11922
+ tabId: number | undefined,
11923
+ zoomSettings: ZoomSettings,
11924
+ callback: () => void,
11925
+ ): void;
11926
+
12185
11927
  /**
12186
11928
  * Gets the current zoom settings of a specified tab.
12187
- * @since Chrome 42
12188
- * @param callback Called with the tab's current zoom settings.
12189
- * Parameter zoomSettings: The tab's current zoom settings.
11929
+ *
11930
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11931
+ * @param tabId The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12190
11932
  */
11933
+ export function getZoomSettings(tabId?: number): Promise<ZoomSettings>;
12191
11934
  export function getZoomSettings(callback: (zoomSettings: ZoomSettings) => void): void;
12192
- /**
12193
- * Gets the current zoom settings of a specified tab.
12194
- * @since Chrome 42
12195
- * @return The `getZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom settings.
12196
- */
12197
- export function getZoomSettings(): Promise<ZoomSettings>;
12198
- /**
12199
- * Gets the current zoom settings of a specified tab.
12200
- * @since Chrome 42
12201
- * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12202
- * @param callback Called with the tab's current zoom settings.
12203
- * Parameter zoomSettings: The tab's current zoom settings.
12204
- */
12205
- export function getZoomSettings(tabId: number, callback: (zoomSettings: ZoomSettings) => void): void;
12206
- /**
12207
- * Gets the current zoom settings of a specified tab.
12208
- * @since Chrome 42
12209
- * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
12210
- * @return The `getZoomSettings` method provides its result via callback or returned as a `Promise` (MV3 only). The tab's current zoom settings.
12211
- */
12212
- export function getZoomSettings(tabId: number): Promise<ZoomSettings>;
12213
- /**
12214
- * Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
12215
- * @since Chrome 54
12216
- * @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.
12217
- * @return The `discard` method provides its result via callback or returned as a `Promise` (MV3 only).
12218
- */
12219
- export function discard(tabId?: number): Promise<Tab>;
11935
+ export function getZoomSettings(
11936
+ tabId: number | undefined,
11937
+ callback: (zoomSettings: ZoomSettings) => void,
11938
+ ): void;
11939
+
12220
11940
  /**
12221
11941
  * Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
11942
+ *
11943
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11944
+ * @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..
12222
11945
  * @since Chrome 54
12223
- * @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.
12224
- * @param callback Called after the operation is completed.
12225
- */
12226
- export function discard(callback: (tab: Tab) => void): void;
12227
- export function discard(tabId: number, callback: (tab: Tab) => void): void;
12228
- /**
12229
- * Go forward to the next page, if one is available.
12230
- * @since Chrome 72
12231
- * @return The `goForward` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12232
11946
  */
12233
- export function goForward(): Promise<void>;
11947
+ export function discard(tabId?: number): Promise<Tab | undefined>;
11948
+ export function discard(callback: (tab?: Tab) => void): void;
11949
+ export function discard(tabId: number | undefined, callback: (tab?: Tab) => void): void;
11950
+
12234
11951
  /**
12235
11952
  * Go forward to the next page, if one is available.
11953
+ *
11954
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11955
+ * @param tabId The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12236
11956
  * @since Chrome 72
12237
- * @param callback Optional. Called after the operation is completed.
12238
11957
  */
11958
+ export function goForward(tabId?: number): Promise<void>;
12239
11959
  export function goForward(callback: () => void): void;
12240
- /**
12241
- * Go forward to the next page, if one is available.
12242
- * @since Chrome 72
12243
- * @param tabId Optional. The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12244
- * @return The `goForward` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12245
- */
12246
- export function goForward(tabId: number): Promise<void>;
12247
- /**
12248
- * Go forward to the next page, if one is available.
12249
- * @since Chrome 72
12250
- * @param tabId Optional. The ID of the tab to navigate forward; defaults to the selected tab of the current window.
12251
- * @param callback Optional. Called after the operation is completed.
12252
- */
12253
- export function goForward(tabId: number, callback: () => void): void;
12254
- /**
12255
- * Go back to the previous page, if one is available.
12256
- * @since Chrome 72
12257
- * @return The `goBack` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12258
- */
12259
- export function goBack(): Promise<void>;
11960
+ export function goForward(tabId: number | undefined, callback: () => void): void;
11961
+
12260
11962
  /**
12261
11963
  * Go back to the previous page, if one is available.
11964
+ *
11965
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11966
+ * @param tabId The ID of the tab to navigate back; defaults to the selected tab of the current window.
12262
11967
  * @since Chrome 72
12263
- * @param callback Optional. Called after the operation is completed.
12264
11968
  */
11969
+ export function goBack(tabId?: number): Promise<void>;
12265
11970
  export function goBack(callback: () => void): void;
12266
- /**
12267
- * Go back to the previous page, if one is available.
12268
- * @since Chrome 72
12269
- * @param tabId Optional. The ID of the tab to navigate back; defaults to the selected tab of the current window.
12270
- * @return The `goBack` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12271
- */
12272
- export function goBack(tabId: number): Promise<void>;
12273
- /**
12274
- * Go back to the previous page, if one is available.
12275
- * @since Chrome 72
12276
- * @param tabId Optional. The ID of the tab to navigate back; defaults to the selected tab of the current window.
12277
- * @param callback Optional. Called after the operation is completed.
12278
- */
12279
- export function goBack(tabId: number, callback: () => void): void;
12280
- /**
12281
- * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
12282
- * @since Chrome 88
12283
- * @param options Configurations object
12284
- * @return The `group` method provides its result via callback or returned as a `Promise` (MV3 only).
12285
- */
12286
- export function group(options: GroupOptions): Promise<number>;
11971
+ export function goBack(tabId: number | undefined, callback: () => void): void;
11972
+
12287
11973
  /**
12288
11974
  * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
11975
+ *
11976
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
12289
11977
  * @since Chrome 88
12290
- * @param options Configurations object
12291
- * @return The `group` method provides its result via callback or returned as a `Promise` (MV3 only).
12292
11978
  */
12293
11979
  export function group(options: GroupOptions): Promise<number>;
12294
- /**
12295
- * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
12296
- * @since Chrome 88
12297
- * @param options Configurations object
12298
- * @param callback Optional.
12299
- */
12300
11980
  export function group(options: GroupOptions, callback: (groupId: number) => void): void;
11981
+
12301
11982
  /**
12302
11983
  * Removes one or more tabs from their respective groups. If any groups become empty, they are deleted
11984
+ *
11985
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
11986
+ * @param tabIds The tab ID or list of tab IDs to remove from their respective groups.
12303
11987
  * @since Chrome 88
12304
- * @param tabIds The tabs to ungroup.
12305
- * @return The `ungroup` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
12306
- */
12307
- export function ungroup(tabIds: number | number[]): Promise<void>;
12308
- /**
12309
- * Removes one or more tabs from their respective groups. If any groups become empty, they are deleted
12310
- * @since Chrome 88
12311
- * @param tabIds The tabs to ungroup.
12312
- * @param callback Optional. Called after the operation is completed.
12313
- */
12314
- export function ungroup(tabIds: number | number[], callback: () => void): void;
12315
- /**
12316
- * Fired when the highlighted or selected tabs in a window changes.
12317
- * @since Chrome 18
12318
11988
  */
12319
- export var onHighlighted: TabHighlightedEvent;
11989
+ export function ungroup(tabIds: number | [number, ...number[]]): Promise<void>;
11990
+ export function ungroup(tabIds: number | [number, ...number[]], callback: () => void): void;
11991
+
11992
+ /** Fired when the highlighted or selected tabs in a window changes */
11993
+ export const onHighlighted: events.Event<
11994
+ (highlightInfo: OnHighlightedInfo) => void
11995
+ >;
11996
+
12320
11997
  /** Fired when a tab is closed. */
12321
- export var onRemoved: TabRemovedEvent;
11998
+ export const onRemoved: events.Event<
11999
+ (tabId: number, removeInfo: OnRemovedInfo) => void
12000
+ >;
12001
+
12322
12002
  /** Fired when a tab is updated. */
12323
- export var onUpdated: TabUpdatedEvent;
12003
+ export const onUpdated: events.Event<
12004
+ (tabId: number, changeInfo: OnUpdatedInfo, tab: Tab) => void
12005
+ >;
12006
+
12324
12007
  /** Fired when a tab is attached to a window, for example because it was moved between windows. */
12325
- export var onAttached: TabAttachedEvent;
12326
- /**
12327
- * 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.
12328
- */
12329
- export var onMoved: TabMovedEvent;
12330
- /** Fired when a tab is detached from a window, for example because it is being moved between windows. */
12331
- export var onDetached: TabDetachedEvent;
12332
- /** 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. */
12333
- export var onCreated: TabCreatedEvent;
12334
- /**
12335
- * 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.
12336
- * @since Chrome 18
12337
- */
12338
- export var onActivated: TabActivatedEvent;
12339
- /**
12340
- * Fired when a tab is replaced with another tab due to prerendering or instant.
12341
- * @since Chrome 26
12342
- */
12343
- export var onReplaced: TabReplacedEvent;
12008
+ export const onAttached: events.Event<
12009
+ (tabId: number, attachInfo: OnAttachedInfo) => void
12010
+ >;
12011
+
12012
+ /** 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}. */
12013
+ export const onMoved: events.Event<
12014
+ (tabId: number, moveInfo: OnMovedInfo) => void
12015
+ >;
12016
+
12017
+ /** Fired when a tab is detached from a window; for example, because it was moved between windows. */
12018
+ export const onDetached: events.Event<
12019
+ (tabId: number, detachInfo: OnDetachedInfo) => void
12020
+ >;
12021
+
12022
+ /** 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. */
12023
+ export const onCreated: events.Event<(tab: Tab) => void>;
12024
+
12025
+ /** 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 */
12026
+ export const onActivated: events.Event<
12027
+ (activeInfo: OnActivatedInfo) => void
12028
+ >;
12029
+
12030
+ /** Fired when a tab is replaced with another tab due to prerendering or instant */
12031
+ export const onReplaced: events.Event<
12032
+ (addedTabId: number, removedTabId: number) => void
12033
+ >;
12034
+
12344
12035
  /**
12345
- * @deprecated since Chrome 33. Please use tabs.onActivated.
12346
12036
  * Fires when the selected tab in a window changes.
12037
+ *
12038
+ * MV2 only
12039
+ * @deprecated Please use {@link tabs.onActivated}.
12347
12040
  */
12348
- export var onSelectionChanged: TabSelectedEvent;
12041
+ export const onSelectionChanged: events.Event<
12042
+ (tabId: number, selectInfo: OnSelectionChangedInfo) => void
12043
+ >;
12044
+
12349
12045
  /**
12350
- * @deprecated since Chrome 33. Please use tabs.onActivated.
12351
- * 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.
12046
+ * 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.
12047
+ *
12048
+ * MV2 only
12049
+ * @deprecated Please use {@link tabs.onActivated}.
12352
12050
  */
12353
- export var onActiveChanged: TabSelectedEvent;
12051
+ export const onActiveChanged: events.Event<
12052
+ (tabId: number, selectInfo: OnActiveChangedInfo) => void
12053
+ >;
12054
+
12354
12055
  /**
12355
- * @deprecated since Chrome 33. Please use tabs.onHighlighted.
12356
12056
  * Fired when the highlighted or selected tabs in a window changes.
12057
+ *
12058
+ * MV2 only
12059
+ * @deprecated Please use {@link tabs.onHighlighted}.
12357
12060
  */
12358
- export var onHighlightChanged: TabHighlightedEvent;
12359
- /**
12360
- * Fired when a tab is zoomed.
12361
- * @since Chrome 38
12362
- */
12363
- export var onZoomChange: TabZoomChangeEvent;
12061
+ export const onHighlightChanged: events.Event<
12062
+ (selectInfo: OnHighlightChangedInfo) => void
12063
+ >;
12364
12064
 
12365
- /**
12366
- * An ID which represents the absence of a browser tab.
12367
- * @since Chrome 46
12368
- */
12369
- export var TAB_ID_NONE: -1;
12065
+ /** Fired when a tab is zoomed */
12066
+ export const onZoomChange: events.Event<
12067
+ (ZoomChangeInfo: OnZoomChangeInfo) => void
12068
+ >;
12370
12069
  }
12371
12070
 
12372
12071
  ////////////////////