jhen0409 / react-chrome-extension-boilerplate

Boilerplate for Chrome Extension React.js project
MIT License
2.14k stars 388 forks source link

How would I add a content script? #73

Closed Dottenpixel closed 7 years ago

Dottenpixel commented 7 years ago

I have a need to manipulate the DOM in my extension and need a content script, but not sure how that fits in this structure

10S10 commented 7 years ago

@Dottenpixel I had facing same issue as you.

But Solution is here. add content.pug. content.js and Reference this .js file in to .pug file same as popup.js . Also don't forgot to mention content.js file in to menifest.dev.js -> entry point.

If you are not mention right path then you will not get the .html file.

All you need to just make content.js same way as popup.js.

jhen0409 commented 7 years ago

We used chrome.tabs.executeScript instead of defined content script because we can't define the content script in development mode. See also: chrome/extension/background/inject.js and Programmatic injection of Content Scripts from official docs.

HuangZurong commented 5 years ago

image image