How Can I Access Firefox Extension Resources
How can I access firefox extension data from javascript code injected directly to the page? I´m looking for something similar to web_accessible_resources key in manifest.json for
Solution 1:
AFAIK that is not allowed.
Can you specify the type of resource you are trying to read?
If it is a script - you can load the script content into content script, and then add it using script tag by injecting it into DOM of page Script
//content scriptvar resourceData = self.data.load(NAME);
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.innerText = resurceData;
head.appendChild(script);
If it is text/xml/html/json - you can pass it using window.postMessage(). An example is shown here a link
You may also find it useful to write a method in Content script that listens for a message event in content script, and on receiving a message in content script from Page Script, you could post back to Page Script using window.postMessage() with the resource data
Post a Comment for "How Can I Access Firefox Extension Resources"