Via the context-menu
module I detect over which DOM element the user clicked my custom context menu item "Mark":
var menu = require("context-menu").Item({
label: "Mark",
contentScriptFile: data.url("context.js"),
onMessage: function (node) {
//Send the node to page-mod
}
});
context.js
:
self.on("click", function (node, data) {
self.postMessage(node);
});
Now I want to send this node reference to a page-mod
module where every page having the pagemod's contentScript injected gets to know the node I clicked on (and mark the HTML element with a red border in every tab).
I know that sending the message to the pagemod via postMessage()
is not possible, so how can I make these modules communicate? Is there an elegant worker
solution?
This isn't possible, the postMessage part is JSONifying your message, so the node in the message is ignored. You'll have you achieve your goal by sending data about the node to the addon context (using postMessage) instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With