I read at working with content scripts that one can use port with context-menu, but the following code gives me an error: cm.port is undefined. The same code works with require("panel")
when I emit an event, but not with context menu. What am doing wrong?
This is main.js
const data = require('self').data;
var cm = require("context-menu").Item({
label: "asdasd",
contentScriptFile: data.url("panel.js")
});
cm.port.emit("myEvent", "panel is showing");
this panel.js
console.log("entering the panel.js file...");
self.on("click", function(node,data) {
self.port.emit("asd");
});
self.port.on("myEvent", function(data) {
console.log(data);
});