[Optimoz] Re: Gestures for Google and ieview (Joe Bernacki),>

flabbergasted at gmx.de flabbergasted at gmx.de
Tue Dec 6 20:55:46 EST 2005


Hi,

this is a striped down version of what I use for this. This opens a new 
tab in foreground, searches for the selected word in Google if it 
doesn't look like a link. If it does, it just tries to load it. And if 
it is started on a link it loads the link.

This works in 1.07. Don't know if it still works in 1.5 as I haven't 
switched yet. But it shouldn't be hard to customize.

Have fun,

Tobias

if(globalOnLink && globalOnLink.length > 0) { // if starting on a link
    var tab = gBrowser.addTab(globalOnLink[0].href, getReferrer(document));
    gBrowser.selectedTab = tab;
    mgMarkLinkVisited(globalOnLink[0]);
} else {
     var sel = mgGetSelection().toString(); // Get selected text
     if (sel != "") {
         if(!(sel.indexOf(" ")>=0) && sel.indexOf(".")>0 && 
sel.indexOf(".") < sel.length-1){ // looks like a link -> load it
             var tab = gBrowser.addTab(sel, getReferrer(document));
             gBrowser.selectedTab = tab;
         } else {
             var searchURL = "http://www.google.com/search?q="+ sel + 
"&hl=en&ie=UTF-8"
             gBrowser.selectedTab = gBrowser.addTab(searchURL);
         }
     } else { // open new tab in foreground
         BrowserOpenTab(); // mozilla function
     }
}




More information about the Optimoz mailing list