MDN / scripting.RegisteredContentScript
MDN / 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:
boolean. If specifiedtrue, 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 tofalse, meaning that only the top frame is matched.
css:
arrayofstring. The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array.
cssOrigin:
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:
arrayofstring. 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:
arrayofstring. 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:
arrayofstring. Array of the pages this content script is injected into. Must be specified for .
matchOriginAsFallback:
boolean. Whether code is injected intoabout:,data:, andblob:pages when their origin matches the pattern inmatches, even if the document origin is opaque (due to the use of CSP or iframe sandbox). Match patterns inmatchesmust specify a wildcard path glob. Defaults tofalse.
persistAcrossSessions:
boolean. Specifies if this content script persists across browser restarts and updates and extension restarts. Defaults totrue.When an extension updates, content scripts are cleared. To restore scripts, add code to the extension’s event handler that responds to the"update"reason.
runAt: . Specifies when JavaScript files are injected into the web page. The default value is
document_idle. In Firefox,runAtalso affects the point where the CSS is inserted. In Chrome,runAtdoes not affect the CSS insertion point.
world: . The execution environment for a script to execute in. The default value is
ISOLATED.
Browser compatibility
This API is based on Chromium’s chrome.scripting API.