scripting.RegisteredContentScript

This object contains details of a script to be registered or that is registered.

Type

Values of this type are objects. They contain these properties:

allFrames Optional

boolean. If specified true, the script is 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 does not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched.

css Optional

array of string. The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array.

cssOrigin Optional

string. The style origin for the injection, either "user", to add the CSS as a user stylesheet, or "author", to add it as an author stylesheet. Defaults to "author". This property is case insensitive in Firefox and Safari.

excludeMatches Optional

array of string. Array of pages that this content script is excluded from but would otherwise be injected into.

id

string. The ID of the content script, specified in the API call.

js Optional

array of string. Array of path to JavaScript files in the extension package to inject into matching pages. Scripts are injected in the order they appear in this array.

matches Optional

array of string. Array of the pages this content script is injected into. Must be specified for scripting.registerContentScripts().

matchOriginAsFallback Optional

boolean. Whether code is injected into about:, data:, and blob: pages when their origin matches the pattern in matches, even if the document origin is opaque (due to the use of CSP or iframe sandbox). Match patterns in matches must specify a wildcard path glob. Defaults to false.

persistAcrossSessions Optional

boolean. Specifies if this content script persists across browser restarts and updates and extension restarts. Defaults to true.

Note: When an extension updates, content scripts are cleared. To restore scripts, add code to the extension's runtime.onInstalled event handler that responds to the "update" reason.

runAt Optional

extensionTypes.RunAt. Specifies when JavaScript files are injected into the web page. The default value is document_idle. In Firefox, runAt also affects the point where the CSS is inserted. In Chrome, runAt does not affect the CSS insertion point.

world Optional

scripting.ExecutionWorld. The execution environment for a script to execute in. The default value is ISOLATED.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
RegisteredContentScript
Chrome – Full support
Chrome 96 (Release date: 2021-11-15)
footnote Full support
Edge – Full support
Edge 96 (Release date: 2021-11-19)
footnote Full support
Firefox – Full support
Firefox 102 (Release date: 2022-06-28)
footnote Full support
Opera – Full support
Opera 82 (Release date: 2021-12-02)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 102 (Release date: 2022-06-28)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support
cssOrigin
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 144 (Release date: 2025-10-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18 (Release date: 2024-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 144 (Release date: 2025-10-14)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18 (Release date: 2024-09-16)
footnote Full support
matchOriginAsFallback
Chrome – Full support
Chrome 119 (Release date: 2023-10-31)
footnote Full support
Edge – Full support
Edge 119 (Release date: 2023-11-02)
footnote Full support
Firefox – Full support
Firefox 128 (Release date: 2024-07-09)
footnote Full support
Opera – Full support
Opera 105 (Release date: 2023-11-14)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Firefox for Android – Full support
Firefox for Android 128 (Release date: 2024-07-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
persistAcrossSessions
Chrome – Full support
Chrome 96 (Release date: 2021-11-15)
footnote Full support
Edge – Full support
Edge 96 (Release date: 2021-11-19)
footnote Full support
Firefox – Full support
Firefox 102 (Release date: 2022-06-28)
footnote
footnote Since Firefox 105, this option is optional and accepts any boolean value.
footnote Prior to Firefox 105, this option was required and only accepted the false value.
Opera – Full support
Opera 82 (Release date: 2021-12-02)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote
footnote Available for use in Manifest V2 or later.
Firefox for Android – Full support
Firefox for Android 102 (Release date: 2022-06-28)
footnote
footnote Since Firefox for Android 105, this option is optional and accepts any boolean value.
footnote Prior to Firefox for Android 105, this option was required and only accepted the false value.
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote
footnote Available for use in Manifest V2 or later.
world
Chrome – Full support
Chrome 102 (Release date: 2022-05-24)
footnote Full support
Edge – Full support
Edge 102 (Release date: 2022-05-31)
footnote Full support
Firefox – Full support
Firefox 128 (Release date: 2024-07-09)
footnote Full support
Opera – Full support
Opera 88 (Release date: 2022-06-08)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 128 (Release date: 2024-07-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

Note: This API is based on Chromium's chrome.scripting API.