阅读:2890回复:4
Open in new tab脚本在34.05失效,求助// ==UserScript== // @name open_in_new_tab // @description Open in new tab // @compatibility Firefox 3.0+ // @author GOLF-AT // @version 1.6.201200204 (function() { /*open bookmark/history in new tab */ try { eval("whereToOpenLink = " + whereToOpenLink.toString().replace( /var shift/,"var Class=e.target.getAttribute('class'); try " +"{ if (Class=='') Class=e.target.parentNode.getAttribute('" +"class');} catch(e) {} Browser=getTopWin().document.getEle" +"mentById('content'); if ((!IsBlankPage(Browser.currentURI" +".spec)|| Browser.webProgress.isLoadingDocument) && Class " +"&& (Class=='sidebar-placesTreechildren'||Class=='placesTr" +"ee'||Class.indexOf('bookmark-item')>=0)) return 'tab'; $&" )); }catch(e){} /*open home in new tab */ try { eval("BrowserGoHome = " + BrowserGoHome.toString().replace( /switch \(where\) {/, "where = (gBrowser.currentURI.spec!=" +"'about:blank' || gBrowser.webProgress.isLoadingDocument"+ ") ? 'tab' : 'current'; $&")); }catch(e){} /*open search in new tab */ try { var searchbar = document.getElementById("searchbar"); eval("searchbar.handleSearchCommand="+searchbar.handleSearchCommand. toString().replace(/this.doSearch\(textValue, where\);/, "if (!gBrowser.webProgress.isLoadingDocument && gBrowser.curren" +"tURI.spec=='about:blank') where='current'; else where='tab'; " +"$&")); }catch(e){} })(); function _LoadURL(aTriggeringEvent, aPostData) { var where = (gBrowser.currentURI.spec!='about:blank' || gBrowser.webProgress.isLoadingDocument) ? 'tab' : 'current'; if (gURLBar.value!='') openUILinkIn(gURLBar.value, where); return true; } function IsBlankPage(url) { return url=="" || url=="about:blank" || url=="about:home" || url=="about:newtab"; }RT 也不是全部失效,主要是搜索结果不能新标签页打开了。 在搜索框点击搜索都是直接覆盖当前页面打开,不知道是不是新的搜索规则改变之后出现的问题。 @GOLF-AT 求助 |
|
1楼#
发布于:2014-12-06 11:38
上面的代码,也就是 url 部分,我自己电脑上后来修改过。搜索栏部分,没修改过。
// ==UserScript== // @name open_in_new_tab // @description Open in new tab // @compatibility Firefox 3.0+ // @author GOLF-AT // @version 1.7.20131112 (function() { /*open bookmark/history in new tab */ try { eval("whereToOpenLink = " + whereToOpenLink.toString().replace( /var shift/,"var Class=e.target.getAttribute('class'); try " +"{ if (Class=='') Class=e.target.parentNode.getAttribute('" +"class');} catch(e) {} Browser=getTopWin().document.getEle" +"mentById('content'); if ((!IsBlankPage(Browser.currentURI" +".spec)|| Browser.webProgress.isLoadingDocument) && Class " +"&& (Class=='sidebar-placesTreechildren'||Class=='placesTr" +"ee'||Class.indexOf('bookmark-item')>=0)) return 'tab'; $&" )); }catch(e){} /*open url in new tab */ try { try { // firefox 3.0.* eval("BrowserLoadURL = "+ BrowserLoadURL.toString().replace( /if \(aTriggeringEvent instanceof MouseEvent\) {/, "_LoadURL(aTriggeringEvent, aPostData); return; $&")); } catch(e) { // firefox 3.1+ var urlbar = document.getElementById("urlbar"); eval("urlbar.handleCommand="+ urlbar.handleCommand.toString( ).replace("aTriggeringEvent.altKey && ", "").replace( "altEnter && !isTabEmpty","!isMouseEvent && !isTabEmpty" )); } }catch(e){} /*open home in new tab */ try { eval("BrowserGoHome = " + BrowserGoHome.toString().replace( /switch \(where\) {/, "where = (gBrowser.currentURI.spec!=" +"'about:blank' || gBrowser.webProgress.isLoadingDocument"+ ") ? 'tab' : 'current'; $&")); }catch(e){} /*open search in new tab */ try { var searchbar = document.getElementById("searchbar"); eval("searchbar.handleSearchCommand="+searchbar.handleSearchCommand. toString().replace(/this.doSearch\(textValue, where\);/, "if (!gBrowser.webProgress.isLoadingDocument && gBrowser.curren" +"tURI.spec=='about:blank') where='current'; else where='tab'; " +"$&")); }catch(e){} })(); function _LoadURL(aTriggeringEvent, aPostData) { var where = (gBrowser.currentURI.spec!='about:blank' || gBrowser.webProgress.isLoadingDocument) ? 'tab' : 'current'; if (gURLBar.value!='') openUILinkIn(gURLBar.value, where); return true; } function IsBlankPage(url) { return url=="" || url=="about:blank" || url=="about:home" || url=="about:newtab"; } |
|
2楼#
发布于:2014-12-06 20:38
|
|
3楼#
发布于:2014-12-06 23:06
看了 Firefox 的代码,Firefox 33 下仍然可以,但是 Firefox 34 下失效了。
已经更新版本了,见我的帖子:https://www.firefox.net.cn/read-24895 1. 支持最新版 Firefox 2. 支持 “侧边栏”中的书签和历史,“我的足迹”中的书签,在新标签页打开。 |
|
4楼#
发布于:2014-12-06 23:53
GOLF-AT:看了 Firefox 的代码,Firefox 33 下仍然可以,但是 Firefox 34 下失效了。非常感谢GOLF-AT更新,确实能在新标签页打开了。 ![]() |
|