I wanted to create a search add-on to right click and search tag text into Wikipedia/ but when i apply this code it only shows the option in context menu but nothing happens//
i don't know where the error is....
i was planning on right clicking it and making it search different words from the same page thispage and get results in a new tab... //
My code:
exports.main = function() {
var contextMenu = require("context-menu");
var tabs = require("tabs");
var Request = require('request');
var menuItem = contextMenu.Item({
label: "Start Search",
context: contextMenu.PageContext(),
contentScript: 'self.on("click", function() {'+
'var text = window.getElementsByTagName(\"td\").toString();'+
'self.postMessage(text);'+
'});',
onMessage: function(text) {
tabs.open("http://en.wikipedia.org/wiki/Special:Search="+text)
}
}) ;
}