From 3be36e1d7c1846ba5abe6535dcc75cd6b3de4708 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 24 Aug 2013 20:25:52 +0900 Subject: [PATCH] keysnail.js: open bookmarks in new tab --- _keysnail.js | 56 +++++++++++----------------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index d46bba9..f91efe0 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -12,7 +12,7 @@ // command.kill.textLengthMax = 8192; // Original is at https://gist.github.com/Griever/62715 -ext.add("open-bookmark-in-new-tab", function(){ +ext.add("open-bookmarks-in-new-tab", function(){ // this makes all clicks open in new tab. // return; // test if firefox 12 @@ -20,50 +20,18 @@ ext.add("open-bookmark-in-new-tab", function(){ getService(Ci.nsIXULAppInfo).version)) { return; } - window.whereToOpenLink = function(e, ib, ia){ return "tab"; }; - // var whereToOpenLink_org = window.whereToOpenLink; - // eval('window.whereToOpenLink = ' + whereToOpenLink_org.toString() - // .replace('if (ctrl', 'if (true') - // ); - // .replace('if (ctrl', 'if (ctrl && !shift|| !ctrl && shift') - // .replace('if (shift ||', 'if (shift && ctrl ||') - // .replace('middle && middleUsesTabs', - // 'middle && middleUsesTabs && !alt') + // window.whereToOpenLink = function(e, ib, ia){ return "tab"; }; + // if no modifier key pressed open in new tab. + var whereToOpenLink_org = window.whereToOpenLink; + eval('window.whereToOpenLink = ' + whereToOpenLink_org.toString() + .replace('{', + '{ if(!e || ' + + '(!e.ctrlKey && !e.shiftKey && !e.metaKey && ' + + '!(e.altKKey && !ignoreAlt))) ' + + 'return "tab";') + ); }, "open in new tab"); -ext.exec("open-bookmark-in-new-tab"); - -// function whereToOpenLink( e, ignoreButton, ignoreAlt ) -// { -// // This method must treat a null event like a left click without modifier keys (i.e. -// // e = { shiftKey:false, ctrlKey:false, metaKey:false, altKey:false, button:0 }) -// // for compatibility purposes. -// if (!e) -// return "current"; - -// var shift = e.shiftKey; -// var ctrl = e.ctrlKey; -// var meta = e.metaKey; -// var alt = e.altKey && !ignoreAlt; - -// // ignoreButton allows "middle-click paste" to use function without always opening in a new window. -// var middle = !ignoreButton && e.button == 1; -// var middleUsesTabs = getBoolPref("browser.tabs.opentabfor.middleclick", true); - -// // Don't do anything special with right-mouse clicks. They're probably clicks on context menu items. - -// //@line 152 "/builds/slave/rel-m-rel-osx64_bld-0000000000/build/browser/base/content/utilityOverlay.js" -// if (meta || (middle && middleUsesTabs)) -// //@line 156 "/builds/slave/rel-m-rel-osx64_bld-0000000000/build/browser/base/content/utilityOverlay.js" -// return shift ? "tabshifted" : "tab"; - -// if (alt && getBoolPref("browser.altClickSave", false)) -// return "save"; - -// if (shift || (middle && !middleUsesTabs)) -// return "window"; - -// return "current"; -// } +ext.exec("open-bookmarks-in-new-tab"); ////////////////////////////////////// //// sitelocalkeymap