User:Epicgenius/google.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Google lookup

function GoogleLookup () {
    var q = "" + (window.getSelection ? window.getSelection()
                                      : document.getSelection ? document.getSelection()
                                                              : document.selection.createRange().text);
    if (!q)
        q = prompt("You didn't select any text.  Enter a search phrase:", "");
    if (q!=null)
        // location="http://www.google.com/search?q=" + escape(q).replace(/ /g, "+");
        window.open("http://www.google.com/search?q=" + escape(q).replace(/ /g, "+") ,'new-tab') ;
 }
 
 window.Google=function() {
  	
 addToolboxLink(0, 'javascript:{GoogleLookup();};void(0);', 'Google', 'toolbox_googlelookup');
 
 }