forked from Griever/userChromeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabsInTitlebar_mod.uc.js
134 lines (110 loc) · 4.54 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
// ==UserScript==
// @name TabsInTitlebar_mod.uc.js
// @description 標準の TabsInTitlebar を改変して常に利用する
// @namespace http://d.hatena.ne.jp/Griever/
// @author Griever
// @include main
// @version 0.0.1
// @compatibility Firefox 4
// ==/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);
});
var titlebar = document.getElementById("titlebar");
var spacer = document.createElement("hbox");
spacer.setAttribute("id", "tabs-in-titlebar-spacer");
titlebar.appendChild(spacer);
if (typeof updateAppButtonDisplay_org == "undefined")
updateAppButtonDisplay_org = updateAppButtonDisplay;
eval("updateAppButtonDisplay = " + updateAppButtonDisplay_org.toString()
.replace(
'document.getElementById("titlebar").hidden = !displayAppButton;',
<![CDATA[
var drawInTitlebar = Services.prefs.getBoolPref(TabsInTitlebar._prefName);
if (!displayAppButton)
displayAppButton = drawInTitlebar;
document.getElementById("titlebar").hidden = !displayAppButton;
]]>.toString()
)
.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");
let titlebarSpacer = $("tabs-in-titlebar-spacer");
if (allowed) {
titlebar.style.marginBottom = "";
titlebarSpacer.style.minHeight = "";
docElement.setAttribute("tabsintitlebar", "true");
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 minHeight = titlebarHeight - tabsHeight > 4 ? 0 : tabsHeight - titlebarHeight + 4;
this._sizePlaceholder("appmenu-button", rect(appmenuButtonBox).width);
this._sizePlaceholder("caption-buttons", rect(captionButtonsBox).width);
titlebar.style.marginBottom = - tabsHeight + "px";
titlebarSpacer.style.minHeight = minHeight + "px";
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 {
docElement.removeAttribute("tabsintitlebar");
titlebar.style.marginBottom = "";
titlebarSpacer.style.minHeight = "";
}
}
addStyle(css)
TabsInTitlebar._update();
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);
}
})(<![CDATA[
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
#main-window[tabsintitlebar="true"] #TabsToolbar {
-moz-box-ordinal-group: 1 !important;
}
#main-window[tabsintitlebar="true"] #toolbar-menubar > .titlebar-placeholder {
display: none;
}
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) {
background: none !important;
}
]]>.toString());