I have tried to insert a js file called “popup/do.js” into mainifest.json file in the “background” and “browser_action” but it didn’t working with the “default_popup”: “popup/index.html” .
How can I fix this problem , please ?
Note : the “popup/do.js” file is userd into the popup menu of the add-no in the toolbar of the browser.
When I contact the support they said that :
We don’t allow add-ons to use remote scripts because they can create serious security vulnerabilities. We also need to review all add-on code, and this makes it much more difficult. Please insert those scripts locally from your add-on code.
eg: do.js
I was using the element into the of popup html page then upload to AMO , then they reply that :
We don’t allow add-ons to use remote scripts because they can create serious security vulnerabilities. We also need to review all add-on code, and this makes it much more difficult. Please insert those scripts locally from your add-on code.
eg: do.js
Should I require the js script using element into the last of the element ?
You have to put a copy of the script file in the folder that contains your manifest.json (or any folder therein).
If you want the script to run in your popup (browser_action or page_action), you need to add a <script> tag in its .html file pointing at the script file, e.g. <script src="/popup/do.js"></script>.
What you can not do is use scripts from remote servers, e.g. <script src="https://some.cdn.com/popup/do.js"></script>.
Everything is clear now , but you mean I can insert this into the <head> element or I should insert it into the <body> element of the popup’s .html file ?
That doesn’t really matter. The only non-cosmetic difference would be the load order, if you have multiple <script> tags, and how far the DOM is built when your script gets executed. If you don’t wait for DOMContentLoaded, your script will only be able to use elements defined above it.