forked from alice0775/userChrome.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patchForBug437791_Sidebar.uc.js
92 lines (92 loc) · 2.94 KB
/
patchForBug437791_Sidebar.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
// ==UserScript==
// @name patchForBug437791_Sidebar_Close_Button_Sometimes_Does_Not_Work.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Bug 437791 - Sidebar close button sometimes does not work; "sidebarBroadcaster is null" in the error console
// @include main
// @compatibility Firefox 3.0 3.1
// @author Alice0775
// @Note
// @version 2008/11/07 00:00
// ==/UserScript==
if ("gSidebarCommand" in window) {
(function(){
var func = toggleSidebar.toString();
func = func.replace(
'commandID = sidebarBox.getAttribute("sidebarcommand");',
<><![CDATA[
commandID = sidebarBox.getAttribute("sidebarcommand") || gSidebarCommand;
]]></>
);
func = func.replace(
'sidebarBox.setAttribute("sidebarcommand", "");',
<><![CDATA[
$&
gSidebarCommand = ""
]]></>
);
func = func.replace(
'sidebarBox.setAttribute("sidebarcommand", sidebarBroadcaster.id);',
<><![CDATA[
$&
gSidebarCommand = sidebarBroadcaster.id;
]]></>
);
eval("window.toggleSidebar = " + func);
})();
} else {
(function(){
var sidebarBox = document.getElementById("sidebar-box");
window.gSidebarCommand = sidebarBox.getAttribute("sidebarcommand");
var func = toggleSidebar.toString();
func = func.replace(
'commandID = sidebarBox.getAttribute("sidebarcommand");',
<><![CDATA[
commandID = sidebarBox.getAttribute("sidebarcommand") || gSidebarCommand;
if (!commandID) return;
]]></>
);
func = func.replace(
'sidebarBox.setAttribute("sidebarcommand", "");',
<><![CDATA[
$&
gSidebarCommand = ""
]]></>
);
func = func.replace(
'sidebarBox.setAttribute("sidebarcommand", sidebarBroadcaster.id);',
<><![CDATA[
$&
gSidebarCommand = sidebarBroadcaster.id;
]]></>
);
eval("window.toggleSidebar = " + func);
})();
if ("toggleSidebar_org" in window) {
(function(){
var sidebarBox = document.getElementById("sidebar-box");
window.gSidebarCommand = sidebarBox.getAttribute("sidebarcommand");
var func = toggleSidebar_org.toString();
func = func.replace(
'commandID = sidebarBox.getAttribute("sidebarcommand");',
<><![CDATA[
commandID = sidebarBox.getAttribute("sidebarcommand") || gSidebarCommand;
]]></>
);
func = func.replace(
'sidebarBox.setAttribute("sidebarcommand", "");',
<><![CDATA[
$&
gSidebarCommand = ""
]]></>
);
func = func.replace(
'sidebarBox.setAttribute("sidebarcommand", sidebarBroadcaster.id);',
<><![CDATA[
$&
gSidebarCommand = sidebarBroadcaster.id;
]]></>
);
eval("window.toggleSidebar_org = " + func);
})();
}
}