I was wondering if it was possible to add CSS to pages through a CSS file, similarly to adding JS to pages through a JS file (contentscript). So, I could just define what pages said CSS file would work on and then it would take effect just like a contentscript. I understand that it is possible to add CSS through a JavaScript file, but it would be more convenient to do it this way instead if possible. If it's not possible, then of course I must use contentscript, but I would first like to know before I rule out any possibilities. I've searched and received no answers - either I'm searching wrong or it really isn't possible. Chrome extensions have come a long way, though, so I'm still not ruling it out until someone who knows can tell me yes & how or no. Thanks for any responses.
相关问题
- How does same-domain policy apply to background sc
- YouTube Data API v3 allowed referers for browser a
- Chrome Extension: How can I get global settings in
- Keep receiving Login Required error when trying to
- chrome.runtime.reload blocking the extension
相关文章
- Progressive web app(PWA) vs Electron vs Browser ex
- chrome.runtime.getURL vs. chrome.extension.getURL
- Will this hotkey work for Mac users?
- Chrome extension permission for “about:blank” page
- getElementById not working in Google Chrome extens
- Google Chrome extension: How to find out if a user
- How can my Chrome plugin disable itself via Javasc
- How to package Firefox and Chrome extensions
Your manifest file must contain a
content script
pointing to aCSS file
, that will load when a urlmatches
your selected url fields...This is the same method you would use to inject
javascript code
, except you would point to ajs file
instead...More information here...
similarly like we add JavaScript in
content_scripts
also add CSSMethod-1
add one more thing on
web_accessible_resources
if you used any external JavaScript then also add URL in permission tab.
Method-2
also same this thing using vai programming injection and insertCSS().
NOTE :
web_accessible_resources
add.css
is not mandatory but as of chrome extension forum is good practice.manifest.json:
content-script.js:
My extension using jQuery