-
Notifications
You must be signed in to change notification settings - Fork 74
/
TabPlus.uc.js
58 lines (52 loc) · 2.51 KB
/
TabPlus.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ==UserScript==
// @name TabPlus.uc.js
// @description 自用整合版标签增强
// @namespace TabPlus@gmail.com
// @include chrome://browser/content/browser.xul
// @include chrome://browser/content/bookmarks/bookmarksPanel.xul
// @include chrome://browser/content/history/history-panel.xul
// @include chrome://browser/content/places/places.xul
// @Note 2014.09.18 最后一次修正整合 by defpt
// ==/UserScript==
(function() {
// 新标签打开:书签、历史、搜索栏
try {
eval('openLinkIn=' + openLinkIn.toString().
replace('w.gBrowser.selectedTab.pinned', '(!w.isTabEmpty(w.gBrowser.selectedTab) || $&)').
replace(/&&\s+w\.gBrowser\.currentURI\.host != uriObj\.host/, ''));
}catch(e){}
// 地址栏新标签打开
try {
location=="chrome://browser/content/browser.xul" &&
eval("gURLBar.handleCommand="+gURLBar.handleCommand.toString().replace(/^\s*(load.+);/gm,
"if(/^javascript:/.test(url)||isTabEmpty(gBrowser.selectedTab)){loadCurrent();}else{this.handleRevert();gBrowser.loadOneTab(url, {postData: postData, inBackground: false, allowThirdPartyFixup: true});}"));
}catch(e){}
//中键点击bookmark菜单不关闭
try {
eval('BookmarksEventHandler.onClick =' + BookmarksEventHandler.onClick.toString().replace('node.hidePopup()', ''));
eval('checkForMiddleClick =' + checkForMiddleClick.toString().replace('closeMenus(event.target);', ''));
} catch(e) {}
//右键关闭标签页,ctrl+右键打开菜单
gBrowser.mTabContainer.addEventListener("click",
function(e) {
if (e.target.localName == "tab" && e.button == 2 && !e.ctrlKey) {
e.preventDefault();
gBrowser.removeTab(e.target);
e.stopPropagation();
}
},
false);
// 关闭当前标签页回到左边标签
try {
eval("gBrowser._blurTab = " + gBrowser._blurTab.toString().replace('this.selectedTab = tab;', "this.selectedTab = aTab.previousSibling? aTab.previousSibling : tab;"));
}catch(e){};
//自动关闭下载产生的空白标签
eval("gBrowser.mTabProgressListener = " + gBrowser.mTabProgressListener.toString().replace(/(?=var location)/, '\
if (aWebProgress.DOMWindow.document.documentURI == "about:blank"\
&& aRequest.QueryInterface(nsIChannel).URI.spec != "about:blank") {\
aWebProgress.DOMWindow.setTimeout(function() {\
!aWebProgress.isLoadingDocument && aWebProgress.DOMWindow.close();\
}, 100);\
}\
'));
})();