I have a Chrome extension that should apply custom CSS rules to the matched website. I want to make small adjustments to the CSS that gets applied based on options set in the extension options via the default_popup html file.
I can't use a CSS content script because that can't be programmatically controlled. It's all or nothing.
So what I want is for my Javascript content script to read the saved options from chrome.storage.sync and then inject the appropriate CSS files based on the just read options.
However, to use injectCSS() requires access to chrome.tabs --- yet chrome.tabs cannot be used in a content script!
This must be a common thing. Suggestions on how to accomplish this using the Chrome extension APIs?
chrome.extension.getURL.insertCSS(). The third answer, which talks about flicker, does not. I expect the third answer that recommends againstinsertCSSbecause it causes rendering flicker may no longer be an issue due to Chrome updates over the last four years of development. The first answer, suggestinggetURL, has the same problem aschrome.tabs: neither are allowed from content scripts!getURLis allowed in content scripts. I don't know why you think it's not.