I want to run the addon [main.js] function from the contents of the script.i read firefox docs, but it does not work for me. These are white papers between the scripts https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port
this is my main.js code
var tabs = require("sdk/tabs");
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "http://mydomain/x.html",
contentScriptFile: data.url("listen.js")
});
self.port.on("myAddonMessage", function(myAddonMessagePayload) {
console.log("working");
});
this is my content listen.js script
var myContentScriptMessagePayload="hi";
self.port.emit("myContentScriptMessage", myContentScriptMessagePayload);
In fact, I expect console.log ("working"); this way out. but it does not work. Can someone help me, I'm really confused here. I really want to call the main.js function from listen.js.
user3003149
source
share