DEV Community

Discussion on: "Hacking" My Way to Automatic File Injection in Chrome Extensions

Collapse
 
chan_austria777 profile image
chan 🤖

Isn't it possible to add the css file in content_scripts in manifest.json to inject it on page load?

Collapse
 
nizarmah profile image
Nizar • Edited

Ah, yes there is. There is content_scripts where you can specify url matches, javascript, and css files. There's actually a good reason why I didn't use them, if I recall correctly.

So the reason is that you need permissions to run it. So, it requires user interaction and the user to "allow it to run" every time this page is opened. I wanted a more "automatic" injection where the user doesn't have to interact with the extension. The approach I took eliminates any need for any permissions.