How do you use Chrome Extensions to change CSS of a web site?

前端 未结 3 1527
一整个雨季
一整个雨季 2021-02-07 20:28

I\'m looking to create an extension for personal and possibly personal friend usage as well that simply changes a few colors that are displayed on a website I visit. I use Reddi

相关标签:
3条回答
  • 2021-02-07 21:04

    There are already extensions made for this. The one I use is called Stylish, which only modifies appearance using CSS3 only, and not html. There are other extensions as well, do some google searches and you will find a few more.

    0 讨论(0)
  • 2021-02-07 21:05

    Instead of an extension, you could also do it in a user script. Then you can simply use GM_addStyle, just like with Greasemonkey scripts. It's much simpler to write and more lightweight in terms of memory usage.

    0 讨论(0)
  • 2021-02-07 21:07

    You can do exactly as you said: you can inject a CSS file or code into the page. The easiest way is through the manifest (look at the CSS property).

    You only need to complete your manifest.json in order for Chrome to know in which pages it has to insert your CSS file into.

    If you want to decide programatically when to insert the CSS, you can use chrome.tabs.insertCSS(), where you can insert a CSS file or just the code as a string.

    0 讨论(0)
提交回复
热议问题