contentScripts.RegisteredContentScript.unregister()
Unregisters the content scripts represented by this RegisteredContentScript
object.
Syntax
registered.unregister()
Parameters
None.
Return value
None.
Browser compatibility
Report problems with this compatibility data on GitHubwebextensions-desktop | webextensions-mobile | |||||
---|---|---|---|---|---|---|
unregister | ChromeNo supportNo
| EdgeNo supportNo
| FirefoxFull support59 | OperaNo supportNo | SafariNo supportNo
| Firefox for AndroidFull support59 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Examples
This code toggles a registered content script on a browser action click:
var registered = null;
async function register() {
registered = await browser.contentScripts.register({
matches: ["*://*.org/*"],
js: [{
code: "document.body.innerHTML = '<h1>This page has been eaten<h1>'"
}],
runAt: "document_idle"
});
}
function toggle() {
if (registered) {
registered.unregister();
registered = null;
} else {
register();
}
}
browser.browserAction.onClicked.addListener(toggle);