scripting.getRegisteredContentScripts()
Returns all the content scripts registered with scripting.registerContentScripts()
or a subset of the registered scripts when using a filter.
Note: This method is available in Manifest V3 or higher in Chrome and Firefox 101. In Firefox 102+, this method is also available in Manifest V2.
To use this API you must have the "scripting"
permission and permission for the page's URL, either explicitly as a host permission or using the activeTab permission.
This is an asynchronous function that returns a Promise
.
Syntax
let scripts = await browser.scripting.getRegisteredContentScripts(
filter
)
Examples
This example returns all the registered content scripts:
await browser.scripting.registerContentScripts([
{
id: "script-1",
js: ["script-1.js"],
matches: ["*://example.com/*"],
},
{
id: "script-2",
js: ["script-2.js"],
matches: ["*://example.com/*"],
},
]);
let scripts = await browser.scripting.getRegisteredContentScripts();
console.log(scripts.map((script) => script.id));
scripts = await browser.scripting.getRegisteredContentScripts({
ids: ["script-2"],
});
console.log(scripts.map((script) => script.id));
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
getRegisteredContentScripts |
88 |
88 |
102 |
? |
74 |
16.4Available for use in Manifest V2 or later.
|
? |
? |
102 |
? |
16.4Available for use in Manifest V2 or later.
|
? |