I'm afraid I haven't figured out how the communication between scripts via port works.
Within panel.js I listen for a submit button to be pressed in the panel. I save values in an array vals and pass them with:
self.port.emit("submitted", vals);
listen in main.js with:
panel.port.on("submitted", function(vals) { ... });
and now I would like to send vals to another content script ('page.js') which will use the data in order to manipulate the DOM of a site.
On main.js I tried:
require("page-mod").PageMod({
include: "*",
contentScriptWhen: 'end',
contentScriptFile: data.url("page.js"),
onAttach: function(worker) {
panel.on('submitted', function(vals) {
worker.port.emit('output', vals);
});
}
});