Creating a search add-on for collecting data

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….

  • How to detect if chrome sync feature is active? - Chrome Extension
  • Using jQuery in Firefox Addons
  • Creating this kind of popup in Firefox Addons?
  • GoogleChrome extension that deletes browsing history with one click from an icon
  • Firefox WebExtension settings page
  • Understanding firefox extension code
  • 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)
                    }
        }) ;
    

    }

  • Creating this kind of popup in Firefox Addons?
  • Understanding firefox extension code
  • Can node-webkit C++ addon write to ImageData object created in JavaScript context?
  • Firefox WebExtension settings page
  • Accessing cookies, hopefully in JavaScript
  • Create a node.js native extension on Windows
  • 2 Solutions collect form web for “Creating a search add-on for collecting data”

    I have found the following error in your script,

    'var elements=document.getElementsByTagName('td'); " +
    

    should be

    'var elements=document.getElementsByTagName(\'td\'); " +
    

    test this:

    exports.main = function() {
    
        var contextMenu = require("context-menu");
        var tabs = require("tabs");     
    
        var menuItem = contextMenu.Item({
            label: "Start Search",
            context: contextMenu.PageContext(),
            contentScript: 'self.on("click", function() {'+
            'var elements=document.getElementsByTagName("td");' +
                    "for(i=0;i<elements.length;i++) { " +
                    "self.postMessage(elements);"+
                                "});",
            onMessage: function(elements) {
                            tabs.open("http://en.wikipedia.org/wiki/Special:Search"+elements);
                        }                        
            }) ;
    
        };