Has anyone here built a browser extension?
Asked by
CreativeCactus92
I'm trying to build a browser extension and I need some help. I'm looking for a way to make my service worker utilize functions from a website. When I try to do something like `document.querySelector("foo").bar.doFunction()`, it works in my Chrome browser at the top level, but I can't seem to get it to work with my service worker. Any advice?
Answers
I've got a simple example of browser extension communication that might help you out. Check it out here: https://github.com/molvqingtai/comctx/tree/master/examples/browser-extension. It could clarify how to structure your code!
Reply to this answer
It sounds like you're at a tricky stage. I recommend checking out some tutorials to get a solid grasp on the basics. Chrome and Mozilla have some great resources that could help you along the way.
Reply to this answer
You might want to explore extension message passing. Setting up a message event listener in your service worker and sending messages from your content script could help with the communication you're looking for.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions