@types/chrome 0.0.329 → 0.0.330

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. chrome/README.md +1 -1
  2. chrome/index.d.ts +159 -132
  3. chrome/package.json +2 -2
chrome/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for chrome (https://developer.chrome.com/
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 01 Jul 2025 19:32:44 GMT
11
+ * Last updated: Tue, 08 Jul 2025 15:36:49 GMT
12
12
  * Dependencies: [@types/filesystem](https://npmjs.com/package/@types/filesystem), [@types/har-format](https://npmjs.com/package/@types/har-format)
13
13
 
14
14
  # Credits
chrome/index.d.ts CHANGED
@@ -9802,11 +9802,22 @@ declare namespace chrome {
9802
9802
  * @since Chrome 88, MV3
9803
9803
  */
9804
9804
  export namespace scripting {
9805
- /* The CSS style origin for a style change. */
9806
- export type StyleOrigin = "AUTHOR" | "USER";
9805
+ /** The origin for a style change. See style origins for more info. */
9806
+ export enum StyleOrigin {
9807
+ AUTHOR = "AUTHOR",
9808
+ USER = "USER",
9809
+ }
9807
9810
 
9808
- /* The JavaScript world for a script to execute within. */
9809
- export type ExecutionWorld = "ISOLATED" | "MAIN";
9811
+ /**
9812
+ * The JavaScript world for a script to execute within.
9813
+ * @since Chrome 95
9814
+ */
9815
+ export enum ExecutionWorld {
9816
+ /** Specifies the isolated world, which is the execution environment unique to this extension. */
9817
+ ISOLATED = "ISOLATED",
9818
+ /** Specifies the main world of the DOM, which is the execution environment shared with the host page's JavaScript. */
9819
+ MAIN = "MAIN",
9820
+ }
9810
9821
 
9811
9822
  export interface InjectionResult<T extends any = any> {
9812
9823
  /**
@@ -9819,100 +9830,162 @@ declare namespace chrome {
9819
9830
  * @since Chrome 90
9820
9831
  */
9821
9832
  frameId: number;
9822
- /* The result of the script execution. */
9823
- result?: T | undefined;
9833
+ /** The result of the script execution. */
9834
+ result?: T;
9824
9835
  }
9825
9836
 
9826
- export interface InjectionTarget {
9827
- /* Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if frameIds is specified. */
9828
- allFrames?: boolean | undefined;
9829
- /**
9830
- * The IDs of specific documentIds to inject into. This must not be set if frameIds is set.
9831
- * @since Chrome 106
9832
- */
9833
- documentIds?: string[] | undefined;
9834
- /* The IDs of specific frames to inject into. */
9835
- frameIds?: number[] | undefined;
9836
- /* The ID of the tab into which to inject. */
9837
- tabId: number;
9838
- }
9837
+ export type InjectionTarget =
9838
+ & {
9839
+ /** The ID of the tab into which to inject. */
9840
+ tabId: number;
9841
+ }
9842
+ & (
9843
+ | {
9844
+ /** 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. */
9845
+ allFrames?: boolean | undefined;
9846
+ /**
9847
+ * The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set.
9848
+ * @since Chrome 106
9849
+ */
9850
+ documentIds?: never | undefined;
9851
+ /** The IDs of specific frames to inject into. */
9852
+ frameIds?: never | undefined;
9853
+ }
9854
+ | {
9855
+ /** 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. */
9856
+ allFrames?: false | undefined;
9857
+ /**
9858
+ * The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set.
9859
+ * @since Chrome 106
9860
+ */
9861
+ documentIds?: never | undefined;
9862
+ /** The IDs of specific frames to inject into. */
9863
+ frameIds: number[] | undefined;
9864
+ }
9865
+ | {
9866
+ /** 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. */
9867
+ allFrames?: false | undefined;
9868
+ /**
9869
+ * The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set.
9870
+ * @since Chrome 106
9871
+ */
9872
+ documentIds?: string[] | undefined;
9873
+ /** The IDs of specific frames to inject into. */
9874
+ frameIds?: never | undefined;
9875
+ }
9876
+ );
9839
9877
 
9840
- export interface CSSInjection {
9841
- /* A string containing the CSS to inject. Exactly one of files and css must be specified. */
9842
- css?: string | undefined;
9843
- /* 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. */
9844
- files?: string[] | undefined;
9845
- /* The style origin for the injection. Defaults to 'AUTHOR'. */
9846
- origin?: StyleOrigin | undefined;
9847
- /* Details specifying the target into which to insert the CSS. */
9848
- target: InjectionTarget;
9849
- }
9878
+ export type CSSInjection =
9879
+ & {
9880
+ /** The style origin for the injection. Defaults to `'AUTHOR'`. */
9881
+ origin?: `${StyleOrigin}` | undefined;
9882
+ /** Details specifying the target into which to insert the CSS. */
9883
+ target: InjectionTarget;
9884
+ }
9885
+ & (
9886
+ | {
9887
+ /** A string containing the CSS to inject. Exactly one of `files` and `css` must be specified. */
9888
+ css: string;
9889
+ /** The path of the CSS files to inject, relative to the extension's root directory. Exactly one of `files` and `css` must be specified. */
9890
+ files?: never | undefined;
9891
+ }
9892
+ | {
9893
+ /** A string containing the CSS to inject. Exactly one of `files` and `css` must be specified. */
9894
+ css?: never | undefined;
9895
+ /** The path of the CSS files to inject, relative to the extension's root directory. Exactly one of `files` and `css` must be specified. */
9896
+ files: string[];
9897
+ }
9898
+ );
9850
9899
 
9851
9900
  export type ScriptInjection<Args extends any[], Result> =
9852
9901
  & {
9853
- /* Details specifying the target into which to inject the script. */
9902
+ /** Details specifying the target into which to inject the script. */
9854
9903
  target: InjectionTarget;
9855
- /* The JavaScript world for a script to execute within. */
9856
- world?: ExecutionWorld;
9857
- /* 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. */
9904
+ /** The JavaScript "world" to run the script in. Defaults to `ISOLATED`. */
9905
+ world?: `${ExecutionWorld}`;
9906
+ /**
9907
+ * 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.
9908
+ * @since Chrome 102
9909
+ */
9858
9910
  injectImmediately?: boolean;
9859
9911
  }
9860
9912
  & (
9861
9913
  | {
9862
- /* 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. */
9914
+ /** 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. */
9915
+ func?: never | undefined;
9916
+ /** 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. */
9863
9917
  files: string[];
9864
9918
  }
9865
9919
  | ({
9866
- /* 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. */
9920
+ /** 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. */
9867
9921
  func: () => Result;
9922
+ /** 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. */
9923
+ files?: never | undefined;
9868
9924
  } | {
9869
- /* 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. */
9870
- func: (...args: Args) => Result;
9871
- /* The arguments to carry into a provided function. This is only valid if the func parameter is specified. These arguments must be JSON-serializable. */
9925
+ /** The arguments to pass to the provided function. This is only valid if the `func` parameter is specified. These arguments must be JSON-serializable. */
9872
9926
  args: Args;
9927
+ /** 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. */
9928
+ func: (...args: Args) => Result;
9929
+ /** 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. */
9930
+ files?: never | undefined;
9873
9931
  })
9874
9932
  );
9875
9933
 
9876
9934
  type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
9877
9935
 
9878
- interface RegisteredContentScript {
9879
- id: string;
9880
- allFrames?: boolean;
9881
- matchOriginAsFallback?: boolean;
9882
- css?: string[];
9883
- excludeMatches?: string[];
9884
- js?: string[];
9885
- matches?: string[];
9886
- persistAcrossSessions?: boolean;
9887
- runAt?: extensionTypes.RunAt;
9888
- world?: ExecutionWorld;
9889
- }
9936
+ /** @since Chrome 96 */
9937
+ type RegisteredContentScript =
9938
+ & {
9939
+ /** 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. */
9940
+ id: string;
9941
+ /** 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. */
9942
+ allFrames?: boolean | undefined;
9943
+ /** Excludes pages that this content script would otherwise be injected into. See Match Patterns for more details on the syntax of these strings. */
9944
+ excludeMatches?: string[] | undefined;
9945
+ /**
9946
+ * 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.
9947
+ * @since Chrome 119
9948
+ */
9949
+ matchOriginAsFallback?: boolean | undefined;
9950
+ /** 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}. */
9951
+ matches?: string[] | undefined;
9952
+ /** Specifies if this content script will persist into future sessions. The default is true. */
9953
+ persistAcrossSessions?: boolean | undefined;
9954
+ /** Specifies when JavaScript files are injected into the web page. The preferred and default value is `document_idle`. */
9955
+ runAt?: extensionTypes.RunAt | undefined;
9956
+ /** The JavaScript "world" to run the script in. Defaults to `ISOLATED`. */
9957
+ world?: `${ExecutionWorld}` | undefined;
9958
+ }
9959
+ & (
9960
+ | {
9961
+ /** The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. */
9962
+ js: string[];
9963
+ /** 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. */
9964
+ css?: string[] | undefined;
9965
+ }
9966
+ | {
9967
+ /** The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. */
9968
+ js?: string[] | undefined;
9969
+ /** 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. */
9970
+ css: string[];
9971
+ }
9972
+ );
9890
9973
 
9891
- interface ContentScriptFilter {
9892
- ids?: string[];
9893
- css?: string;
9894
- files?: string[];
9895
- origin?: StyleOrigin;
9896
- target?: InjectionTarget;
9974
+ /** @since Chrome 96 */
9975
+ export interface ContentScriptFilter {
9976
+ /** If specified, {@link getRegisteredContentScripts} will only return scripts with an id specified in this list. */
9977
+ ids?: string[] | undefined;
9897
9978
  }
9898
9979
 
9899
9980
  /**
9900
- * Injects a script into a target context. The script will be run at document_end.
9901
- * @param injection
9902
- * The details of the script which to inject.
9903
- * @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.
9981
+ * 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.
9982
+ *
9983
+ * Can return its result via Promise since Chrome 90.
9984
+ * @param injection The details of the script which to inject.
9904
9985
  */
9905
9986
  export function executeScript<Args extends any[], Result>(
9906
9987
  injection: ScriptInjection<Args, Result>,
9907
9988
  ): Promise<Array<InjectionResult<Awaited<Result>>>>;
9908
-
9909
- /**
9910
- * Injects a script into a target context. The script will be run at document_end.
9911
- * @param injection
9912
- * The details of the script which to inject.
9913
- * @param callback
9914
- * Invoked upon completion of the injection. The resulting array contains the result of execution for each frame where the injection succeeded.
9915
- */
9916
9989
  export function executeScript<Args extends any[], Result>(
9917
9990
  injection: ScriptInjection<Args, Result>,
9918
9991
  callback: (results: Array<InjectionResult<Awaited<Result>>>) => void,
@@ -9920,102 +9993,56 @@ declare namespace chrome {
9920
9993
 
9921
9994
  /**
9922
9995
  * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored.
9923
- * @param injection
9924
- * The details of the styles to insert.
9925
- * @return The `insertCSS` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
9996
+ *
9997
+ * Can return its result via Promise since Chrome 90.
9998
+ * @param injection The details of the styles to insert.
9926
9999
  */
9927
10000
  export function insertCSS(injection: CSSInjection): Promise<void>;
9928
-
9929
- /**
9930
- * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored.
9931
- * @param injection
9932
- * The details of the styles to insert.
9933
- * @param callback
9934
- * Invoked upon completion of the injection.
9935
- */
9936
10001
  export function insertCSS(injection: CSSInjection, callback: () => void): void;
9937
10002
 
9938
10003
  /**
9939
10004
  * Removes a CSS stylesheet that was previously inserted by this extension from a target context.
9940
- * @param injection
9941
- * The details of the styles to remove.
9942
- * Note that the css, files, and origin properties must exactly match the stylesheet inserted through `insertCSS`.
9943
- * Attempting to remove a non-existent stylesheet is a no-op.
9944
- * @return This only returns a Promise when the callback parameter is not specified, and with MV3.
10005
+ * @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.
9945
10006
  * @since Chrome 90
9946
10007
  */
9947
10008
  export function removeCSS(injection: CSSInjection): Promise<void>;
9948
-
9949
- /**
9950
- * Removes a CSS stylesheet that was previously inserted by this extension from a target context.
9951
- * @param injection
9952
- * The details of the styles to remove.
9953
- * Note that the css, files, and origin properties must exactly match the stylesheet inserted through `insertCSS`.
9954
- * Attempting to remove a non-existent stylesheet is a no-op.
9955
- * @param callback
9956
- * Invoked upon completion of the removal.
9957
- * @since Chrome 90
9958
- */
9959
10009
  export function removeCSS(injection: CSSInjection, callback: () => void): void;
9960
10010
 
9961
10011
  /**
9962
- * Registers one or more content scripts.
9963
- * @param scripts
10012
+ * Registers one or more content scripts for this extension
10013
+ * @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.
10014
+ * @since Chrome 96
9964
10015
  */
9965
10016
  export function registerContentScripts(scripts: RegisteredContentScript[]): Promise<void>;
9966
-
9967
- /**
9968
- * Registers one or more content scripts.
9969
- * @param scripts
9970
- * @param callback
9971
- */
9972
10017
  export function registerContentScripts(scripts: RegisteredContentScript[], callback: () => void): void;
9973
10018
 
9974
10019
  /**
9975
- * Unregister one or more content scripts.
9976
- * @param filter
9977
- * @param callback
10020
+ * Unregisters content scripts for this extension.
10021
+ * @param filter If specified, only unregisters dynamic content scripts which match the filter. Otherwise, all of the extension's dynamic content scripts are unregistered.
10022
+ * @since Chrome 96
9978
10023
  */
9979
10024
  export function unregisterContentScripts(filter?: ContentScriptFilter): Promise<void>;
9980
-
9981
- /**
9982
- * Unregister one or more content scripts.
9983
- * @param filter
9984
- * @param callback
9985
- */
9986
10025
  export function unregisterContentScripts(callback: () => void): void;
9987
- export function unregisterContentScripts(filter: ContentScriptFilter, callback: () => void): void;
10026
+ export function unregisterContentScripts(filter: ContentScriptFilter | undefined, callback: () => void): void;
9988
10027
 
9989
10028
  /**
9990
- * Returns all the content scripts registered with scripting.registerContentScripts()
9991
- * or a subset of the registered scripts when using a filter.
9992
- * @param filter
10029
+ * Returns all dynamically registered content scripts for this extension that match the given filter.
10030
+ * @param filter An object to filter the extension's dynamically registered scripts.
10031
+ * @since Chrome 96
9993
10032
  */
9994
10033
  export function getRegisteredContentScripts(filter?: ContentScriptFilter): Promise<RegisteredContentScript[]>;
9995
-
9996
- /**
9997
- * Returns all the content scripts registered with scripting.registerContentScripts()
9998
- * or a subset of the registered scripts when using a filter.
9999
- * @param filter
10000
- * @param callback
10001
- */
10002
10034
  export function getRegisteredContentScripts(callback: (scripts: RegisteredContentScript[]) => void): void;
10003
10035
  export function getRegisteredContentScripts(
10004
- filter: ContentScriptFilter,
10036
+ filter: ContentScriptFilter | undefined,
10005
10037
  callback: (scripts: RegisteredContentScript[]) => void,
10006
10038
  ): void;
10007
10039
 
10008
10040
  /**
10009
- * Updates one or more content scripts.
10010
- * @param scripts
10041
+ * Updates one or more content scripts for this extension.
10042
+ * @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.
10043
+ * @since Chrome 96
10011
10044
  */
10012
10045
  export function updateContentScripts(scripts: RegisteredContentScript[]): Promise<void>;
10013
-
10014
- /**
10015
- * Updates one or more content scripts.
10016
- * @param scripts
10017
- * @param callback
10018
- */
10019
10046
  export function updateContentScripts(scripts: RegisteredContentScript[], callback: () => void): void;
10020
10047
  }
10021
10048
 
chrome/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/chrome",
3
- "version": "0.0.329",
3
+ "version": "0.0.330",
4
4
  "description": "TypeScript definitions for chrome",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome",
6
6
  "license": "MIT",
@@ -94,6 +94,6 @@
94
94
  "@types/har-format": "*"
95
95
  },
96
96
  "peerDependencies": {},
97
- "typesPublisherContentHash": "9296926d7f8b66c228d84cfa1bd5cd6fdbadf7e71317c5f29f9c28617b997850",
97
+ "typesPublisherContentHash": "4db1f32e36d67c789a750b22d16655f566e51c49ed1340fe40526cbd240918c4",
98
98
  "typeScriptVersion": "5.1"
99
99
  }