Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

tabs.removeCSS()

Removes from a page CSS which was previously injected by a call to tabs.insertCSS().

Syntax

browser.tabs.removeCSS(
  tabId,           // optional integer
  details,         // extensionTypes.InjectDetails
  callback         // optional function
)

Parameters

tabId Optional
integer. The ID of the tab from which to remove the CSS. Defaults to the active tab of the current window.
details
extensionTypes.InjectDetails. An object describing the CSS to remove from the page. It contains the following properties:
 
allFramesOptional
boolean. If true, the code will be removed from all frames of the current page. If it is false, code is only removed from the top frame. Defaults to false.
codeOptional
string. CSS to remove, as a text string. This must exactly match a CSS string previously inserted into the page using tabs.insertCSS().
fileOptional
string. Path to a file containing the CSS to remove. This must exactly match a CSS file previously inserted into the page using tabs.insertCSS().
frameIdOptional
integer. The frame from which to remove the CSS. Defaults to 0 (the top-level frame).
matchAboutBlankOptional
boolean. If true, the CSS will be removed from embedded "about:blank" and "about:srcdoc" frames if your add-on has access to their parent document. Defaults to false.
callback Optional
function. Called, with no arguments, when the CSS has been removed from the page.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic Support No No 49.0 No No

Compatibility notes

Firefox

  • 'matchAboutBlank' is not supported.

Examples

Remove CSS found in a string

This example removes the CSS found in a string from the currently active tab.

var css = "body { border: 20px dotted pink; }";

chrome.tabs.removeCSS({code: css});

Remove CSS found in an extension-packaged file

This example removes from the active tab CSS loaded from a file.

chrome.tabs.removeCSS({file: "/path/to/content-style.css"});

Remove CSS from a specific tab and its sub-frames

This more intricate call to tabs.removeCSS() removes CSS loaded from a bundled file from the tab whose ID is 5. In addition, the CSS is removed from all frames within the document.

When all of the CSS has been removed, the provided onExecuted() function is called.

function onExecuted() {
  console.log("finished");
}

chrome.tabs.removeCSS(
  5, {
  file: "/path/to/content-style.css",
  allFrames: true
}, onExecuted);

Acknowledgements

This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg, Sheppy
 Last updated by: wbamberg,