forked from overdodactyl/ShadowFox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userChrome.js
106 lines (98 loc) · 4.21 KB
/
userChrome.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
// ==UserScript==7
// @name FloatingScrollbar.uc.js
// @namespace [email protected]
// @include main
// @version 0.0.3
// @note Thanks to Griever(https://github.com/Griever/userChromeJS/blob/master/SmartScrollbar.uc.js) and Paul Rouget(https://gist.github.com/4003205)
// @note...........0.0.3 Fixed a problem of breaking hbox layout
// @note 0.0.2 Remove usage of E4X (https://bugzilla.mozilla.org/show_bug.cgi?id=788293)
// ==/UserScript==
(function () {
var prefs = Services.prefs,
enabled;
if (prefs.prefHasUserValue('userChromeJS.floating_scrollbar.enabled')) {
enabled = prefs.getBoolPref('userChromeJS.floating_scrollbar.enabled')
} else {
prefs.setBoolPref('userChromeJS.floating_scrollbar.enabled', true);
enabled = true;
}
var css = '\
@namespace url(http: //www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);\
:not(select):not(hbox) > scrollbar {\
-moz-appearance: none !important;\
position: relative;\
background-color: transparent;\
background-image: none;\
z-index: 2147483647;\
padding: 2px;\
}\
:not(select):not(hbox) > scrollbar[orient = "vertical"] {\
-moz-margin-start: -10px;\
min-width: 10px;\
}\
:not(select):not(hbox) > scrollbar[orient = "vertical"] thumb {\
min-height: 20px;\
}\
:not(select):not(hbox) > scrollbar[orient = "horizontal"] {\
margin-top: -10px;\
min-height: 10px;\
}\
:not(select):not(hbox) > scrollbar[orient = "horizontal"] thumb {\
min-width: 20px;\
}\
:not(select):not(hbox) > scrollbar thumb {\
-moz-appearance: none !important;\
border-width: 0px !important;\
border-radius: 3px !important;\
background-color: rgba(159, 159, 159, 0.33) !important;\
background-image: linear-gradient(to right,transparent,rgba(255, 255, 255, 0.05),transparent) !important;\
transition: background-color 0.5s ease-in-out;\
}\
:not(select):not(hbox) > scrollbar thumb:active,\
:not(select):not(hbox) > scrollbar thumb:hover {\
background-color: rgba(159, 159, 159, 0.8) !important;\
background-image: linear-gradient(to right,transparent,rgba(255, 255, 255, 0.1),transparent) !important;\
}\
:not(select):not(hbox) > scrollbar:active,\
:not(select):not(hbox) > scrollbar:hover {\
// -moz-margin-start: -14px;\
box-shadow: -1px 0px 2px 1px rgba(100, 110, 120, 0.1);\
}\
:not(select):not(hbox) > scrollbar thumb:active {\
background-color: rgba(159, 159, 159, 1) !important;\
background-image: linear-gradient(to right,transparent,rgba(255, 255, 255, 0.1),transparent) !important;\
transition: background-color 0s ease-in-out;\
}\
:not(select):not(hbox) > scrollbar scrollbarbutton, :not(select):not(hbox) > scrollbar gripper {\
display: none;\
}';
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', "Floating Scrollbar");
m.setAttribute('type', 'checkbox');
m.setAttribute('autocheck', 'false');
m.setAttribute('checked', enabled);
p.parentNode.insertBefore(m, p);
m.addEventListener('command', command, false);
if (enabled) {
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
}
function command() {
if (sss.sheetRegistered(uri, sss.AGENT_SHEET)) {
prefs.setBoolPref('userChromeJS.floating_scrollbar.enabled', false);
sss.unregisterSheet(uri, sss.AGENT_SHEET);
m.setAttribute('checked', false);
} else {
prefs.setBoolPref('userChromeJS.floating_scrollbar.enabled', true);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
m.setAttribute('checked', true);
}
let root = document.documentElement;
let display = root.style.display;
root.style.display = 'none';
window.getComputedStyle(root).display; // Flush
root.style.display = display;
}
})();