I made an extension to the firefox using Add-on Builder tool. the extension structure is like,
main addon code will run 2 content scripts (1 at run and 1 at ready states of document)
the results of content scripts are send to main addon code(using "communication between content script and addon code")
the main addon code sends this information to 1 more content script.
the content script will add the both results and displays when user clicks on a widget
Example:
main.js(addon code):
var data = require("self").data;
var paraPanel = require("panel").Panel({
contentScriptFile: data.url("combine.js")
});
require("page-mod").PageMod({
contentScriptWhen: 'start',
contentScriptFile: data.url("content-script1.js"),
onAttach: function (worker) {
worker.port.on("para1", function(message) {
msgfromscript1 = message;
});
}
})
require("page-mod").PageMod({
contentScriptWhen: 'ready',
contentScriptFile: data.url("content-script2.js"),
onAttach: function (worker) {
worker.port.on("para2", function(message) {
msgfromscript2 = message;
});
}
})
require("widget").Widget({
contentURL: data.url("crack_attack.png"),
onClick: function() {
paraPanel.port.emit("add-para", msgfromscript1,msgfromscript2);
paraPanel.show();
}
});
combine.js code:
self.port.on("add-para", function(msgfromscript1,msgfromscript2) {
var result=msgfromscript1+msgfromscript2;
document.body.innerHTML = result;
});
I want to implement the same functionality as Opera extension. How can I do this communication and the display based on a click functionalities in the Opera browser?
Is there any documentation or example Opera extensions which may help me?
opera extensions documentation: http://dev.opera.com/addons/extensions/ here are two extensions on github: https://github.com/truthee/opera and https://github.com/mywot/opera hope it helps.