the following is a fragment of the "main.js"
code.
My problem is that when I use the "option 1" url
the code works perfectly
but when I use the "option 2" url
, then the functions marked to be exported
on "content-script.js"
(to be seen on "page.html"
) are not properly seen on "page.html"
.
I have all the necessary code to export and communicate things. The key point is just on the pageUrl format. It seems that there is some problem when using file system urls in the form of:
"file:///D:/page.html"
In cases as above (file://
) the "contentScriptFile"
is not included for some reason.
Do I have to make some modification on the security configuration of Firefox,
for example on: "about:config"
area?
Any Idea?
// [option 1] pageUrl = "http://localhost:81/firefox_addon/page.html";
// [option 2] pageUrl = "file:///D:/page.html";
tabs.open({
url: pageUrl,
});
var pageMod = pageMods.PageMod({
include: ["*"],
contentScriptFile: self.data.url("content-script.js"),
onAttach: startListening
});
In your PageMod constructor, you will need to define the file://
schema as well as the *
wildcard.
var data = require('sdk/self').data;
var pageMod = require('sdk/page-mod');
function startListening(){
// noop
}
pageMod.PageMod({
include: ['*', 'file://*'],
contentScriptFile: [
data.url('content-scripts.js')
],
onAttach: startListening
});
This allows the PageMod module to include content scripts on file://
schema's