Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/scripting/getregisteredcontentscripts/index.md
6552 views
------{{AddonSidebar()}}
Returns all the content scripts registered with {{WebExtAPIRef("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
Parameters
filter{{optional_inline}}: {{WebExtAPIRef("scripting.ContentScriptFilter")}}. A filter for the registered script details to return.
Return value
A Promise that fulfills with an array of {{WebExtAPIRef("scripting.RegisteredContentScript")}}. If any error occurs, the promise is rejected.
Examples
This example returns all the registered content scripts:
{{WebExtExamples}}
Browser compatibility
{{Compat}}
Note: This API is based on Chromium's
chrome.scriptingAPI.