forked from alice0775/userChrome.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatchForBug685470.uc.js
124 lines (112 loc) · 3.59 KB
/
patchForBug685470.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// ==UserScript==
// @name patchForBug685470.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Workaround Bug 685470 - Bookmarks tooltip should not pop up when I click the bookmark.( not only bookmarks but also links in contents )
// @include main
// @compatibility Firefox 7.0+
// @author Alice0775
// @version 2011/10/30 formfox?
// @version 2011/10/30 due to Bug 658001 - need to clear mouse capture if the capturing frame is inside a hidden deck panel or hidden tab
// @version 2011/09/17
// @version 2011/09/09
// @version 2011/08/30
// @Note
// ==/UserScript==
var bug685470 = {
noTooltip : false,
get tipNode() {
delete this.tipNode;
return this.tipNode = document.getElementById("aHTMLTooltip");
},
handleEvent: function(event) {
switch (event.type) {
case "mousedown":
this.browserOnMousedown(event);
break;
case "click":
this.browserOnClick(event);
break;
case "unload":
this.uninit();
break;
}
},
init: function() {
window.addEventListener("unload", this, false);
window.addEventListener("mousedown", this, true);
window.addEventListener("click", this, true);
setTimeout(function(self) {self.delayedStartup();}, 1000, this);
},
uninit: function() {
window.removeEventListener("click", this, true);
window.removeEventListener("mousedown", this, true);
window.removeEventListener("unload", this, false);
},
delayedStartup: function() {
if ("__linkformfox__FillInHTMLTooltip" in window &&
!/bug685470/.test(window.__linkformfox__FillInHTMLTooltip.toString())) {
var func = window.__linkformfox__FillInHTMLTooltip.toString();
func = func.replace(
/{/,
<><![CDATA[
$&
if ("bug685470" in window && bug685470.noTooltip) {
return false;
}
]]></>
);
window.__linkformfox__FillInHTMLTooltip = new Function(
func.match(/\((.*)\)\s*\{/)[1],
func.replace(/^function\s*.*\s*\(.*\)\s*\{/, '').replace(/}$/, '')
);
}
if ("FillInHTMLTooltip" in window && !/bug685470/.test(window.FillInHTMLTooltip.toString())) {
var func = window.FillInHTMLTooltip.toString();
func = func.replace(
/{/,
<><![CDATA[
$&
if ("bug685470" in window && bug685470.noTooltip) {
return false;
}
]]></>
);
window.FillInHTMLTooltip = new Function(
func.match(/\((.*)\)\s*\{/)[1],
func.replace(/^function\s*.*\s*\(.*\)\s*\{/, '').replace(/}$/, '')
);
}
},
browserOnMousedown: function(event) {
this.noTooltip = true;
setTimeout(function(self) {
self.noTooltip = false;
}, 500, this);
this.browserOnClick(event);
},
browserOnClick: function(event) {
var elm = event.originalTarget;
var doc = elm.ownerDocument;
if (!doc)
return;
//userChrome_js.debug(doc instanceof HTMLDocument)
if (doc instanceof HTMLDocument)
return;
var win = doc.defaultView;
var tip = doc.evaluate(
'ancestor-or-self::*[@tooltip or @tooltiptext or @title or @alt]',
elm,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
if (!tip)
return;
var evt = doc.createEvent("MouseEvents");
evt.initMouseEvent("mouseout", true, true, win,
0, 0, 0, 0, 0,
false, false, false, false, 0, null);
elm.dispatchEvent(evt);
}
}
bug685470.init();