Content script not executing
Hello everyone,
I was going though the docs and the getting started section. I'm trying to load a content-script as on this page https://docs.plasmo.com/framework/content-scripts and https://github.com/PlasmoHQ/examples/blob/main/with-content-script/content.ts However, when I visit https://www.plasmo.com the script does appear to load/execute for some reason. I'm on firefox, and I've attached my folder structure, the content script and the console from dev tools.
Plasmo Docs
Content Scripts – Plasmo
How to use Plasmo content scripts to inject custom behavior into web pages
GitHub
examples/with-content-script/content.ts at main · PlasmoHQ/examples
🔰 Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - PlasmoHQ/examples
Plasmo
Supercharge your browser extension development
Plasmo is a browser extension development platform that helps you build, publish, and manage your browser extensions.
2 Replies
why are you listening for a
load
event? by default content scripts will inject when document_idle
which could be before OR after the load event .. so just run your code without the event handler
if there's some explicit reason you have to wait for load
event, you can, but when the script runs you can also check for document.readyState == 'complete'
and bypass the event handlerThis was what was in the docs, I just copied it
Also using the debugger I figured out that the event actually does fire, however the console.log never executes and the script script stops execution after console.log is called