I have a very simple extension:
{
"manifest_version": 2,
"name": "User Style Sheet Workaround",
"version": "1",
"content_scripts": [
{
"matches": ["<all_urls>"],
"css": ["default.css"]
}
]
}
I want default.css
to be injected as user origin, not as author origin. How can I do it?
Use chrome.tabs.insertCSS with
cssOrigin: 'user'
in the background script's URL change event.For example, chrome.webNavigation.onCommitted (requires
webNavigation
permission) or chrome.tabs.onUpdated (doesn't require any special permissions).The target sites to allow CSS injection should be added to
permissions
.manifest.json:
bg.js: