THWIT
THWIT

Reputation: 57

Insert CSS in Chrome Extension

I know that it's possible to add CSS to a page with Content_Scripts, but I want to use the InsertCSS function in a JS file.

I have:

chrome.tabs.insertCSS(null, {code: "adfree.css"});

But it doesn't change anything of a webpage. I gave the permissions:

"permissions": [
    "tabs", "*://*"
],

Why doesn't it work?

Edit:

chrome.tabs.insertCSS({file: "adfree.css"});

or

chrome.tabs.insertCSS(null, {file: "adfree.css"});

doesn't work also...

Upvotes: 3

Views: 3198

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 219920

You are passing it a file name, but using the code key, when you should be using the file key:

chrome.tabs.insertCSS(null, {file: "adfree.css"});

See the documentation for more info.

Upvotes: 2

Related Questions