FireGestures: Open in new Tab (Link, Search, Empty) scripts
June 11th, 2009 by Andreas - Posted in FirefoxFireGestures is a very nice add-on for Firefox to navigate very fast through web pages, search for a selected text or other useful commands.
This add-on is downloadable at the mozilla addons page. Two small scripts can improve the standard functionality.
The first script opens a link in a new focused tab or search for the selected text. If nothing is selected and no link was used an empty focused tab will be created.
// (1) Open link in a new Tab - focused var srcNode = FireGestures.sourceNode; var linkURL = FireGestures.getLinkURL(srcNode); if (linkURL) { gBrowser.loadOneTab(linkURL, null, null, null, false, false); return; } // (2) Else if you select a text, search for it - focused var sel = FireGestures.getSelectedText(); if (sel) { var ss = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var submission = ss.currentEngine.getSubmission(sel, null); gBrowser.loadOneTab(submission.uri.spec, null, null, submission.postData, false, false); return; } // (3) Else create new tab - focused if (!linkURL && !sel) { document.getElementById("cmd_newNavigatorTab").doCommand(); return; }
The second script opens a link in a new background tab or search for the selected text.
// (1) Open link in a new Tab - background var srcNode = FireGestures.sourceNode; var linkURL = FireGestures.getLinkURL(srcNode); if (linkURL) { gBrowser.loadOneTab(linkURL, null, null, null, true, false); return; } // (2) Else if you select a text, search for it - background var sel = FireGestures.getSelectedText(); if (sel) { var ss = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var submission = ss.currentEngine.getSubmission(sel, null); gBrowser.loadOneTab(submission.uri.spec, null, null, submission.postData, true, false); return; }
Other useful scripts can be found at the FireGestures homepage.
Tags: Add-ons, Firefox, FireGestures, Mozilla, Script
