UserScripts.UserScriptOptions (Legacy)
The UserScriptOptions object represents the content scripts to register. It has similar syntax to the contentScript options supported by browser.contentScripts.register. The differences are:
> [!WARNING]
> This is documentation for the legacy `userScripts` API. It's available in Firefox for Manifest V2. For functionality to work with user scripts in Manifest V3 see the new userScripts API.
The `UserScriptOptions` object represents the content scripts to register. It has similar syntax to the `contentScript` options supported by `browser.contentScripts.register`. The differences are:
- it does not support a CSS property (use `browser.contentScripts.register` to dynamically register/unregister stylesheets)
- It does support an optional `scriptMetadata` property (as a plain JSON object which contains some metadata properties associated to the registered `userScripts`)
The `UserScriptOptions` object has the following properties:
- `allFrames`
- : Same as `all_frames` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `excludeGlobs`
- : Same as `exclude_globs` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `excludeMatches`
- : Same as `exclude_matches` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `includeGlobs`
- : Same as `include_globs` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `js`
- : An array of objects. Each object has either a property named `file`, which is a URL starting at the extension's manifest.json and pointing to a JavaScript file to register, or a property named `code`, which is some JavaScript code to register.
- `matchAboutBlank`
- : Same as `match_about_blank` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `matches`
- : Same as `matches` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `runAt`
- : Same as `run_at` in the [`content_scripts`](/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts) key.
- `scriptMetadata`
- : A user script metadata value.
It has similar syntax to the `contentScript` options supported by `browser.contentScripts.register`.
Cite this
"UserScripts.UserScriptOptions (Legacy)". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts_legacy/UserScriptOptions JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy