Documentation: Chrome User Scripts API
A promise-based wrapper around the Chrome userScripts API. Note: This API is available in Manifest V3.
- configureUserScriptsWorld(properties?)
- getUserScripts(ids?)
- getUserScriptsWorldConfigs()
- executeUserScript(injection)
- registerUserScripts(scripts)
- resetUserScriptsWorldConfigs(worldId?)
- unregisterUserScripts(ids?)
- updateUserScripts(scripts)
- isAvailableUserScripts()
configureUserScriptsWorld(properties?: chrome.userScripts.WorldProperties): Promise<void>
Configures the execution world for user scripts. If properties is omitted, defaults are used.
getUserScripts(ids?: string[]): Promise<chrome.userScripts.RegisteredUserScript[]>
Retrieves registered user scripts. When ids is provided, returns only scripts with matching IDs.
getUserScriptsWorldConfigs(): Promise<chrome.userScripts.WorldProperties[]>
Returns the currently configured user script worlds.
executeUserScript(injection: chrome.userScripts.UserScriptInjection): Promise<chrome.userScripts.InjectionResult[]>
Executes a user script with the provided injection parameters and resolves with the results from all frames where it executed.
registerUserScripts(scripts: chrome.userScripts.RegisteredUserScript[]): Promise<void>
Registers one or more user scripts.
resetUserScriptsWorldConfigs(worldId?: string): Promise<void>
Resets the configuration of a specific world by ID, or all worlds if worldId is omitted.
unregisterUserScripts(ids?: string[]): Promise<void>
Unregisters user scripts. When ids are provided, only scripts with those IDs are removed; otherwise, all registered scripts are removed.
updateUserScripts(scripts: chrome.userScripts.RegisteredUserScript[]): Promise<void>
Updates previously registered user scripts with new definitions.
isAvailableUserScripts(): booleanReturns true when the userScripts namespace is present on the API selected by browser() in the current context.
Returns false if the namespace or WebExtension environment is absent, or if accessing it throws.
The check is synchronous, does not log, and reads the current API on every call without caching.
It checks namespace presence only; it does not guarantee individual methods, permissions, or a successful operation.
In Chrome, the namespace can remain defined after user-script access is revoked until the context reloads.
This check does not call getScripts() to probe that access. See Chrome’s availability guidance.
import {isAvailableUserScripts} from "@addon-core/browser";
if (isAvailableUserScripts()) {
// The namespace is present; handle operation-specific failures when using it.
}