Reputation: 2385
In my Firefox extension I want to add a JS file to the page.
I tried to do that by adding to the page a script tag with the url to my script:
<script src="chrome://path/to/my/script/file.js" type="text/javascript" async=""></script>
But nothing happens when I add it to the page.
The script is not visible in the devtools (debugger > sources).
When I enter the same url in the address bar - I do see the file.
What am I missing?
Upvotes: 1
Views: 91
Reputation: 37238
You are probably getting a security error, see in browser console it will say chrome url not allowed to be injected. What you have to do is set contentaccessible=true
on the path which you have files which you want to inject - in your chrome.manifest
like this: https://gist.github.com/Noitidart/9406437#file-chrome-manifest-L1
Upvotes: 2