-
Notifications
You must be signed in to change notification settings - Fork 37
/
SmartScrollbar.uc.js
82 lines (71 loc) · 2.45 KB
/
SmartScrollbar.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
// ==UserScript==
// @name SmartScrollbar.uc.js
// @namespace http://d.hatena.ne.jp/Griever/
// @include main
// @version 0.0.5
// @note 0.0.5 Remove E4X
// @note CSS を微調整
// @note SmartScrollbar に改名
// ==/UserScript==
// thx! http://www.geocities.jp/adsldenet/past/sample.html
(function(){
const HIDE_START = true;
const HIDE_ALL = true; // falseならコンテンツの一番外側のスクロールバーのみ有効
const HIDE_SCROLLBAR = false;
// 色、太さは適宜調整
var css = '\
html|html > scrollbar[orient="vertical"] > slider > thumb\
{\
max-width: 3px !important;\
min-width: 3px !important;\
}\
\
html|html > scrollbar[orient="horizontal"] > slider > thumb\
{\
max-height: 3px !important;\
min-height: 3px !important;\
}\
\
html|html > scrollbar > slider > thumb\
{\
-moz-appearance: none !important;\
border: none !important;\
background-color: #0c6 !important;\
}\
\
html|html > scrollbar > scrollbarbutton,\
html|html > resizer\
{\
display: none !important;\
}\
';
if (HIDE_SCROLLBAR)
css = 'html|html > scrollbar { visibility: collapse !important; }';
var NS = '@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");';
NS += '@namespace html url("http://www.w3.org/1999/xhtml");';
css = NS + css;
if (HIDE_ALL)
css = css.replace(/html\|html > /g, 'html|*:not(html|select) > ');
var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
var uri = makeURI('data:text/css;charset=UTF=8,' + encodeURIComponent(css));
var p = document.getElementById('devToolsSeparator');
var m = document.createElement('menuitem');
m.setAttribute('label', "\u30B9\u30AF\u30ED\u30FC\u30EB\u30D0\u30FC\u3092\u8868\u793A\u3057\u306A\u3044");
m.setAttribute('type', 'checkbox');
m.setAttribute('autocheck', 'false');
m.setAttribute('checked', HIDE_START);
p.parentNode.insertBefore(m, p);
m.addEventListener('command', command, false);
if (HIDE_START) {
sss.loadAndRegisterSheet(uri,sss.AGENT_SHEET);
}
function command(){
if (sss.sheetRegistered(uri, sss.AGENT_SHEET)){
sss.unregisterSheet(uri, sss.AGENT_SHEET);
m.setAttribute('checked', false);
} else {
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
m.setAttribute('checked', true);
}
}
})();