-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.min.js
185 lines (180 loc) · 12.6 KB
/
script.min.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
! function(a) {
function b() {
this.event, this.isMuted, this.to_queue, this.to_mute, this.interval = 300, this.init()
}
b.prototype = {
init: function() {
this.event = document.createEvent("Event"), this.event.initEvent("DOMModified", !0, !0), this.isMuted = !1, a.addEventListener("DOMNodeInserted", function(a) {
this.dispatch_with_mute(a)
}.bind(this), !1), a.addEventListener("DOMNodeRemoved", function(a) {
this.dispatch_with_mute(a)
}.bind(this), !1)
},
dispatch_with_mute: function() {
this.isMuted ? (clearTimeout(this.to_queue), this.to_queue = setTimeout(function() {
this.dispatch_with_timer()
}.bind(this), this.interval)) : this.dispatch_with_timer()
},
dispatch_with_timer: function() {
a.dispatchEvent(this.event), this.isMuted = !0, clearTimeout(this.to_mute), this.to_mute = setTimeout(function() {
this.isMuted = !1
}.bind(this), this.interval)
}
}, new b
}(window),
function(a) {
function b(a) {
this.scrollbar_v = document.createElement("div"), this.scrollbar_h = document.createElement("div"), this.scrollrail_v = document.createElement("div"), this.scrollrail_h = document.createElement("div"), this.scrollbar_v.id = "scrollbar-vertical", this.scrollbar_h.id = "scrollbar-horizontal", this.scrollrail_v.id = "scrollrail-vertical", this.scrollrail_h.id = "scrollrail-horizontal", this.rail = {
size: 12,
min_size: 25,
margin: 2,
corner: 6
}, this.zoom_browser, this.zoom_body, this.to, this.grabbedId, this.bar_v, this.bar_h, this.margin_v, this.margin_h, this.cacheY, this.cacheX, this.winHeight, this.winWidth, this.docHeight, this.docWidth, this.computedBodyStyle, this.margin_v = this.rail.margin, this.margin_h = this.rail.margin, this.zoom_browser = 1, this.options = a, this.init()
}
b.prototype = {
init: function() {
"loading" != document.readyState && this.startup(), a.addEventListener("DOMContentLoaded", function() {
this.startup()
}.bind(this), !1)
},
startup: function() {
this.computedBodyStyle = a.getComputedStyle(document.body, null), this.cssHack(), this.scrollrail_v.appendChild(this.scrollbar_v), this.scrollrail_h.appendChild(this.scrollbar_h), document.getElementsByTagName("body")[0].appendChild(this.scrollrail_v), document.getElementsByTagName("body")[0].appendChild(this.scrollrail_h);
var b = this;
a.addEventListener("scroll", function(a) {
b.update(a)
}, !1), a.addEventListener("resize", function(a) {
b.update(a)
}, !1), a.addEventListener("DOMModified", function(a) {
b.refresh(a)
}, !1), this.scrollbar_v.addEventListener("mousedown", function(a) {
b.grabStart(a, this)
}, !1), this.scrollbar_h.addEventListener("mousedown", function(a) {
b.grabStart(a, this)
}, !1), this.scrollrail_v.addEventListener("mousedown", function(a) {
b.slipStart(a, this)
}, !1), this.scrollrail_h.addEventListener("mousedown", function(a) {
b.slipStart(a, this)
}, !1), this.scrollrail_v.addEventListener("mouseover", function(a) {
b.onRail(a, this)
}, !1), this.scrollrail_h.addEventListener("mouseover", function(a) {
b.onRail(a, this)
}, !1), this.scrollrail_v.addEventListener("mouseout", function(a) {
b.offRail(a, this)
}, !1), this.scrollrail_h.addEventListener("mouseout", function(a) {
b.offRail(a, this)
}, !1), a.addEventListener("mousemove", function(a) {
b.grabMove(a)
}, !1), a.addEventListener("mouseup", function(a) {
b.grabEnd(a)
}, !1), this.update()
},
update: function(b) {
this.refresh(b);
var c = document.documentElement.scrollTop + a.innerHeight / 2,
d = document.documentElement.scrollLeft + a.innerWidth / 2;
this.scrollbar_v.style.top = (this.winHeight * (c / this.docHeight) - this.bar_v / 2 + this.margin_v) / this.zoom_body + "px", this.scrollbar_h.style.left = (this.winWidth * (d / this.docWidth) - this.bar_h / 2 + this.margin_h) / this.zoom_body + "px"
},
refresh: function() {
if (this.isHidden()) return !1;
if (this.isFullscreen()) return !1;
document.getElementById("scrollrail-vertical") && document.getElementById("scrollrail-horizontal") || (document.getElementsByTagName("body")[0].appendChild(this.scrollrail_v), document.getElementsByTagName("body")[0].appendChild(this.scrollrail_h)), this.options.autohide ? (this.setVisible(this.scrollbar_v), this.setVisible(this.scrollbar_h), this.setHidden(this.scrollbar_v), this.setHidden(this.scrollbar_h)) : (clearTimeout(this.scrollbar_v.to_autohide), clearTimeout(this.scrollbar_h.to_autohide)), this.scrollrail_v.isActive = a.innerHeight + 1 < document.documentElement.scrollHeight, this.scrollrail_h.isActive = a.innerWidth + 1 < document.documentElement.scrollWidth, this.scrollrail_v.className = this.scrollrail_v.isActive ? "" : "disabled", this.scrollrail_h.className = this.scrollrail_h.isActive ? "" : "disabled";
var b = a.innerHeight - 2 * this.margin_v - (this.scrollrail_h.isActive ? this.rail.corner / this.zoom_browser : 0),
c = a.innerWidth - 2 * this.margin_h - (this.scrollrail_v.isActive ? this.rail.corner / this.zoom_browser : 0),
d = document.documentElement.scrollHeight,
e = document.documentElement.scrollWidth;
if (this.winHeight === b && this.winWidth === c && this.docHeight === d && this.docWidth === e) return !1;
this.winHeight = b, this.winWidth = c, this.docHeight = d, this.docWidth = e, this.zoom_browser = a.outerWidth / a.innerWidth || 1, this.zoom_body = document.body.style.zoom || 1;
var f = this.zoom_browser * this.zoom_body;
this.scrollrail_v.style.width = this.rail.size / f + "px", this.scrollrail_h.style.height = this.rail.size / f + "px", this.scrollbar_v.style.webkitBorderRadius = 5 / f + "px / " + 7 / f + "px", this.scrollbar_h.style.webkitBorderRadius = 14 / f + "px / " + 10 / f + "px", this.scrollbar_v.style.webkitBoxShadow = "0 0 " + 1 / f + "px " + 1 / f + "px rgba(255,255,255,.9)", this.scrollbar_h.style.webkitBoxShadow = "0 0 " + 1 / f + "px " + 1 / f + "px rgba(255,255,255,.9)", this.scrollrail_v.style.borderLeftWidth = 1 / f + "px", this.scrollrail_h.style.borderTopWidth = 1 / f + "px", this.bar_v = this.winHeight * (a.innerHeight / this.docHeight) / this.zoom_body, this.bar_h = this.winWidth * (a.innerWidth / this.docWidth) / this.zoom_body, this.bar_v < this.rail.min_size ? (this.margin_v = this.rail.margin / this.zoom_browser + (this.rail.min_size - this.bar_v) / 2, this.bar_v = this.rail.min_size) : this.margin_v = this.rail.margin / this.zoom_browser, this.bar_h < this.rail.min_size ? (this.margin_h = this.rail.margin / this.zoom_browser + (this.rail.min_size - this.bar_h) / 2, this.bar_h = this.rail.min_size) : this.margin_h = this.rail.margin / this.zoom_browser, this.scrollbar_v.style.height = this.bar_v + "px", this.scrollbar_h.style.width = this.bar_h + "px"
},
isHidden: function() {
var a = "hidden" == this.computedBodyStyle.getPropertyValue("overflow"),
b = a || "hidden" == this.computedBodyStyle.getPropertyValue("overflow-y"),
c = a || "hidden" == this.computedBodyStyle.getPropertyValue("overflow-x");
return this.scrollrail_v.style.display = b ? "none" : "", this.scrollrail_h.style.display = c ? "none" : "", a
},
isFullscreen: function() {
var a = document.webkitIsFullScreen;
return a && (this.scrollrail_v.style.display = "none", console.log("isFullscreen"), this.scrollrail_h.style.display = "none"), a
},
cssHack: function() {
"auto" == this.computedBodyStyle.getPropertyValue("overflow") && this.computedBodyStyle.getPropertyValue(!0) && this.computedBodyStyle.getPropertyValue("height") == a.innerHeight + "px" && (document.body.style.height = "auto")
},
setVisible: function(a) {
a.style.visibility = "visible", a.style.opacity = "", clearTimeout(a.to_autohide)
},
setHidden: function(a) {
return this.grabbedId ? !1 : (a.to_autohide = setTimeout(function() {
a.style.visibility = "hidden", a.style.opacity = 0
}.bind(this), 2500), void 0)
},
grabStart: function(a, b) {
a.preventDefault(), this.grabbedId = b.id, b.className = "hovered", this.cacheY = a.screenY, this.cacheX = a.screenX
},
grabMove: function(a) {
return this.grabbedId ? (document.body.style.pointerEvents = "none", "scrollbar-vertical" == this.grabbedId ? (document.documentElement.scrollTop += (a.screenY - this.cacheY) * (this.docHeight / this.winHeight) / this.zoom_browser, this.cacheY = a.screenY) : (document.documentElement.scrollLeft += (a.screenX - this.cacheX) * (this.docWidth / this.winWidth) / this.zoom_browser, this.cacheX = a.screenX), this.update(), void 0) : !1
},
grabEnd: function() {
return this.grabbedId ? (document.body.style.pointerEvents = "auto", this.grabbedId = !1, this.scrollbar_v.className = "", this.scrollbar_h.className = "", this.options.autohide && (this.setHidden(this.scrollbar_v), this.setHidden(this.scrollbar_h)), void 0) : !1
},
slipStart: function(a, b) {
return this.grabbedId ? !1 : ("scrollrail-vertical" == b.id ? document.documentElement.scrollTop = (a.clientY - this.bar_v / 2) * this.docHeight / this.winHeight : document.documentElement.scrollLeft = (a.clientX - this.bar_h / 2) * this.docWidth / this.winWidth, this.update(), this.grabStart(a, b.childNodes[0]), void 0)
},
onRail: function(a, b) {
this.scrollrail_v.classList.remove("hovered"), this.scrollrail_h.classList.remove("hovered"), b.className = "hovered", clearTimeout(b.to), this.options.autohide && this.setVisible("scrollrail-vertical" == b.id ? this.scrollbar_v : this.scrollbar_h)
},
offRail: function(a, b) {
b.to = setTimeout(function() {
b.className = ""
}.bind(this), 600), this.options.autohide && this.setHidden("scrollrail-vertical" == b.id ? this.scrollbar_v : this.scrollbar_h)
}
}, a.MinimalScrollbar = b
}(window),
function(a) {
function b(a) {
if (!a.excluded) return !1;
for (var b = a.excluded.split(/[,\n] ?/), c = b.length; c--;) {
if (0 === document.URL.indexOf(b[c])) return !0;
if (document.location.host.indexOf(b[c]) > -1) return !0
}
return !1
}
function c() {
var b = a != parent;
return b
}
function d() {
var a = document.createElement("style");
a.innerHTML = "html::-webkit-scrollbar{display:none !important}body::-webkit-scrollbar{display:none !important}", document.getElementsByTagName("body")[0].appendChild(a)
}
function e() {
var a = document.getElementsByTagName("html")[0],
b = document.body,
c = a.style.overflow,
d = b.style.overflow;
a.style.overflow = "hidden", b.style.overflow = "hidden", setTimeout(function() {
a.style.overflow = c, b.style.overflow = d
}, 100)
}
function f() {
var b = document.body.clientWidth == a.innerWidth,
c = document.body.clientHeight == a.innerHeight;
return b && c
}
function g(b) {
"loading" != document.readyState && b(), a.addEventListener("DOMContentLoaded", b, !1)
}
var h = {
autohide: !0,
excluded: "https://chrome.google.com, https://mail.google.com, https://groups.google.com,mail.live.com"
};
! function() {
chrome.storage.sync.get(function(i) {
void 0 !== chrome.extension.lastError && console.log("Error: restoreSettings");
var j = Object.keys(i).length ? i : h;
return b(j) ? !1 : (document.documentElement.setAttribute("data-minimalscrollbar", "yes"), c(j) , c(j) || new a.MinimalScrollbar(j), g(function() {
f() || e() || d()
}), void 0)
})
}()
}(window);