docs.rodeo

MDN Web Docs mirror

userScripts (Legacy)

{{AddonSidebar}} 

[!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 {{WebExtAPIRef("userScripts")}}  API.

Use this API to register user scripts, third-party scripts designed to manipulate webpages or provide new features. Registering a user script instructs the browser to attach the script to pages that match the URL patterns specified during registration.

This API offers similar capabilities to {{WebExtAPIRef("contentScripts")}}  but with features suited to handling third-party scripts:

[!WARNING] This API requires the presence of the user_scripts key in the manifest.json, even if no API script is specified. For example. user_scripts: {}.

To use the API, call {{WebExtAPIRef("userScripts_legacy.register","register()")}}  passing in an object defining the scripts to register. The method returns a Promise that is resolved with a {{WebExtAPIRef("userScripts_legacy.RegisteredUserScript","RegisteredUserScript")}}  object.

[!NOTE] User scripts are unregistered when the related extension page (from which the user scripts were registered) is unloaded, so you should register a user script from an extension page that persists at least as long as you want the user scripts to stay registered.

Types

Methods

Events

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN