-
Notifications
You must be signed in to change notification settings - Fork 123
/
contextOpenLinkInTab.uc.js
80 lines (64 loc) · 2.3 KB
/
contextOpenLinkInTab.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ==UserScript==
// @name contextOpenLinkInTab.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description context menu "Open Link In Tab"
// @include *
// @compatibility Tb3
// @modifier Alice0775
// @version 2009/12/11 Tb3
// ==/UserScript==
var ucjs_OpenLinkInTab = {
contextmenu: null,
init: function( ){
this.contextmenu = document.getElementById("mailContext");
if (!this.contextmenu)
return;
var target = document.getElementById("mailContext-openInBrowser");
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", "Open Link In Tab");
menuitem.setAttribute("id", "contextOpenLinkInTab_menu");
menuitem.setAttribute("oncommand", "ucjs_OpenLinkInTab.openLinkInTab(event);");
target.parentNode.insertBefore(menuitem, target);
this.contextmenu.addEventListener("popupshowing", this, false);
window.addEventListener("unload", this, false);
},
uninit: function() {
this.contextmenu.removeEventListener("popupshowing", this, false);
window.removeEventListener("unload", this, false);
},
handleEvent: function(aEvent) {
switch(aEvent.type) {
case "popupshowing":
this.onPopupshowing(aEvent);
break;
case "unload":
this.uninit();
break;
}
},
onPopupshowing: function(aEvent) {
document.getElementById("contextOpenLinkInTab_menu").hidden = !gContextMenu.onLink;
},
openLinkInTab: function(aEvent) {
var background = aEvent.shiftKey;
var uri = gContextMenu.linkURL;
var mailWindow = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow("mail:3pane");
if (!background)
mailWindow.focus();
var reg = new RegExp(/.*/);// new RegExp("^" + uri.prePath.replace(/\./g, "\\.");
mailWindow.document.getElementById("tabmail")
.openTab(
"contentTab",
{
contentPage: uri,
background: background,
clickHandler: function(event){
specialTabs.siteClickHandler(event, reg);
}
}
);
}
}
ucjs_OpenLinkInTab.init();