The index.js script has no access to any document or any window object. index.js is the main add-on or background script. Its execution environment and context are very specific to the addon SDK.
N.B.: this separation does exist on Chromium add-ons as well. However, a Chromium background page is actually a virtual sort of Web page (with its own DOM). As a matter of fact, on such scripts, this is actually a window object; so you can pretty much access to every standard APIs you’ll find on any Web page. However, you’ll never access directly to the DOM of a Web page the user is browsing from a background script.
Thanks for this. I am now looking at content scripts and the “worker” aspect, the “message system” between the scripts. I am having trouble with that though.
All I need to do now is pass this value “document.querySelectorAll(’[src^=“http://”],[href^=“http: //”],[img^=“http://”]’);” from the content script to the add-on script. Not quite got the hang of it yet.
Thanks.It would be better to have the code on the content script but then I can’t use the different mods “require(“sdk/notifications”);” within the content script?
It really depends of what you want to achieve. Try to design your code architecture with a strong separation of concerns (DDD can help https://en.wikipedia.org/wiki/Domain-driven_design). Eventually, each component of your application will communicate with simple commands or simple data structures.
For instance, you probably just need to pass a string to the background for showing up the notification, don’t you?
Yes, so basically I am looking for any any HTTP within the page. So the add-on script will have an if condition which would then call the content script in order to search for mixed content. The content script would then pass this data back to the add-on for evaluation.
i am trying to develop an addon for my visa application website. I am getting following error like There was an error during installation: Extension is invalid