-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathTabsInTitlebar_mod.uc.js
141 lines (122 loc) · 4.97 KB
/
TabsInTitlebar_mod.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// ==UserScript==
// @name TabsInTitlebar_mod.uc.js
// @description 標準の TabsInTitlebar を改変して常に利用する
// @namespace http://d.hatena.ne.jp/Griever/
// @author Griever
// @include main
// @compatibility Firefox 4
// @version 0.0.2
// @note Remove E4X
// ==/UserScript==
// @SS http://f.hatena.ne.jp/Griever/20110408002650
(function(css){
if (typeof TabsInTitlebar == "undefined") return;
if (typeof TreeStyleTabService != "undefined") return;
// メニューを作成
Array.forEach(document.querySelectorAll('menuitem[command="cmd_ToggleTabsOnTop"]'), function(e) {
var m = document.createElement("menuitem");
m.setAttribute("label", "\u30BF\u30D6\u3092\u30BF\u30A4\u30C8\u30EB\u30D0\u30FC\u306B\u8868\u793A/\u89E3\u9664");
m.setAttribute("oncommand", "Services.prefs.setBoolPref(TabsInTitlebar._prefName, !Services.prefs.getBoolPref(TabsInTitlebar._prefName))");
m.setAttribute("accesskey", "I");
e.parentNode.insertBefore(m, e.nextSibling);
});
if (typeof updateAppButtonDisplay_org == "undefined")
updateAppButtonDisplay_org = updateAppButtonDisplay;
eval("updateAppButtonDisplay = " + updateAppButtonDisplay_org.toString()
.replace(
'document.getElementById("titlebar").hidden = !displayAppButton;',
[
'var drawInTitlebar = Services.prefs.getBoolPref(TabsInTitlebar._prefName);'
,'if (!displayAppButton)'
,' displayAppButton = drawInTitlebar;'
,'document.getElementById("titlebar").hidden = !displayAppButton;'
].join("\n")
)
.replace(
'TabsInTitlebar.allowedBy("drawing-in-titlebar", displayAppButton);',
'TabsInTitlebar.allowedBy("drawing-in-titlebar", drawInTitlebar);'
));
if (typeof TabsInTitlebar._readPref == "undefined")
TabsInTitlebar._readPref_org = TabsInTitlebar._readPref;
TabsInTitlebar._readPref = function () {
updateAppButtonDisplay();
}
if (typeof TabsInTitlebar._update_org == 'undefined')
TabsInTitlebar._update_org = TabsInTitlebar._update;
TabsInTitlebar._update = function () {
if (!this._initialized || window.fullScreen)
return;
let allowed = Services.prefs.getBoolPref(this._prefName);
let docElement = document.documentElement;
/*
if (allowed == (docElement.getAttribute("tabsintitlebar") == "true"))
return;
*/
function $(id) document.getElementById(id);
let titlebar = $("titlebar");
if (allowed) {
let rect = function rect(ele) ele.getBoundingClientRect();
let appmenuButtonBox = $("appmenu-button-container");
let captionButtonsBox = $("titlebar-buttonbox");
let tabsToolbar = $("TabsToolbar");
let titlebarHeight = titlebar.boxObject.height;
let tabsHeight = tabsToolbar.boxObject.height;
let marginBottom = titlebarHeight - 4;
if (marginBottom > tabsHeight)
marginBottom = tabsHeight;
this._sizePlaceholder("appmenu-button", rect(appmenuButtonBox).width);
this._sizePlaceholder("caption-buttons", rect(captionButtonsBox).width);
titlebar.style.marginBottom = - marginBottom + "px";
docElement.setAttribute("tabsintitlebar", "true");
if (!this._draghandle) {
let tmp = {};
Components.utils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp);
this._draghandle = new tmp.WindowDraggingElement(tabsToolbar, window);
this._draghandle.mouseDownCheck = function () {
return !this._dragBindingAlive && this.ownerDocument.documentElement.getAttribute("tabsintitlebar") == "true";
};
}
} else {
titlebar.style.marginBottom = "";
docElement.removeAttribute("tabsintitlebar");
}
}
addStyle(css)
updateAppButtonDisplay();
setTimeout(function(){
TabsInTitlebar._update();
}, 1000);
function addStyle(css) {
var pi = document.createProcessingInstruction(
'xml-stylesheet',
'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'
);
return document.insertBefore(pi, document.documentElement);
}
})('\
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);\
#main-window[tabsintitlebar] #TabsToolbar {\
-moz-box-ordinal-group: 1 !important;\
}\
#main-window[tabsintitlebar] #toolbar-menubar > .titlebar-placeholder {\
display: none;\
}\
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) {\
background: -moz-linear-gradient(rgba(50%,50%,50%,0), ActiveCaption 60%) !important;\
color: CaptionText !important;\
}\
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme):-moz-window-inactive {\
background: -moz-linear-gradient(rgba(50%,50%,50%,0), InactiveCaption 60%) !important;\
color: InactiveCaptionText !important;\
}\
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) #main-menubar> menu,\
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) toolbarbutton {\
color: inherit !important;\
}\
\
#main-window[title="Firefox - タブグループ"] #titlebar-buttonbox-container,\
#main-window[title="Firefox - タブグループ"] #appmenu-button-container\
{\
visibility: hidden !important;\
}\
');