-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAgents.js
More file actions
303 lines (241 loc) · 10.1 KB
/
UserAgents.js
File metadata and controls
303 lines (241 loc) · 10.1 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/* Make SmartTVs recognize cursors */
if (navigator.userAgent.match("SmartTV")) {
document.getElementById("Handler").className += " smart"
}
if (navigator.userAgent.match("Macintosh")) {
document.getElementById("Handler").className += " osx"
}
if (navigator.userAgent.match("Linux")) {
document.getElementById("Handler").className += " xubuntu"
}
/* CSS for App */
if (navigator.userAgent.match("MW18")) {
document.getElementById("Handler").className += " mpisto-servers"
}
// Some old Fox Versions
var ua_agent = navigator.userAgent
if ( (ua_agent.match("Safari/")) && !( (ua_agent.match("Chrome/")) || (ua_agent.match("YNGT")) ) ) { // Safari
window.oldBrowser = ua_agent.match(/Version\/(\d+)/)[1] < 18
window.oldBrowser2 = ua_agent.match(/Version\/(\d+)/)[1] < 18
}
if ( (ua_agent.match("Firefox/")) && !( (ua_agent.match("PaleMoon/")) ) ) { // Mozilla Firefox
window.oldBrowser = ua_agent.match(/Firefox\/(\d+)/)[1] < 127
window.oldBrowser2 = ua_agent.match(/Firefox\/(\d+)/)[1] < 133
}
if ( (ua_agent.match("PaleMoon/")) ) { // Pale Moon
window.oldBrowser = ua_agent.match(/PaleMoon\/(\d+)/)[1] < 32
window.oldBrowser2 = ua_agent.match(/PaleMoon\/(\d+)/)[1] < 32
document.querySelector('html').classList.add('pale-moon')
}
if ( (ua_agent.match("Chrome/")) && !( (ua_agent.match("Edge/")) ) ) { // Google Chrome
window.oldBrowser = ua_agent.match(/Chrome\/(\d+)/)[1] < 125
window.oldBrowser2 = ua_agent.match(/Chrome\/(\d+)/)[1] < 131
}
window.oldBrowser =(
(window.oldBrowser) || // Old Chrome, Firefox and Safari
(ua_agent.match("Trident")) || // Internet Explorer
(ua_agent.match("Presto")) || // Classic Opera
(ua_agent.match("Tessera")) || // 4x4 Browser
(ua_agent.match("MINERVOULA")) || // Older mInerva
(ua_agent.match("Silk")) || // Amazon Silk
(ua_agent.match("PLAYSTATION 3")) || // PS3 Browser
(ua_agent.match("Nintendo DSi")) || // Nintendo DSi Browser
(ua_agent.match("Nintendo 3DS")) || // Nintendo 3DS Browser
(ua_agent.match("PLAYSTATION PORTABLE")) || // PSP Browser
(ua_agent.match("Edge")) || // Classic Microsoft Edge
(ua_agent.match("BlackBerry")) || // Blackberry Browser
(ua_agent.match("IEMobile")) || // Phone Internet Explorer
(ua_agent.match("PaleMoon")) // Pale Moon
)
if (window.oldBrowser) {
window.location.replace("https://hm100.github.io/UnsupportedBanners/Mpisto.html");window.location.href = "https://hm100.github.io/UnsupportedBanners/Mpisto.html";
}
// <!--END-->
/* Mobile Only CSS */
if (('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0)) {
document.querySelector("html").className += " touch-events"
}
if (navigator.userAgent.match("Chrome/")) { // Google Chrome
document.querySelector("html").className += " no-standard-scrollbar"
}
/* Local Storage */
function getKey(key) {
var str = window.localStorage,
result = str.getItem('-evelution-preference-'+key);
if (!result) {
return '-1';
}
return result;
}
function insertKey(key,value) {
window.localStorage.setItem('-evelution-preference-' + key, '' + value);
}
function getParams() {
if (window.location.search != "") {
var params = window.location.search.split("?")[1].split("&");
} else {
var params = []
}
return params
}
/* Dropdowns */
// Calls the function on all toggles
function DropDownUpdate() {
var dropdowns = document.querySelectorAll(".cpe-dropdown");
dropdowns.forEach(function(x) {
x.setAttribute('tabindex',-1); // Add the CPE button class
});
InitialiseSelectInputs();
}
/* Select Inputs */
function InitialiseSelectInputs() {
/* Select Inputs */
var select_items = document.querySelectorAll(".cpe-dropdown.cpe-select .cpe-dropdown__content .cpe-list li:not(.cpe-dropdown-level-nested)");
select_items.forEach(function(y) {
y.setAttribute('onclick','HandleSelectInputBlurring()')
y.addEventListener('click', (function(e) { UpdateSelectInput(this) }) );
});
}
function UpdateSelectInput(obj) { // Updates a Select Input Value
var x = document.querySelector(".cpe-dropdown.cpe-select:focus-within .cpe-dropdown__content .cpe-list li.selected");
if (x) {
x.classList.remove("selected");
}
// obj.classList.add("selected");
document.querySelector(' .cpe-dropdown.cpe-select:focus-within').addEventListener('click',UpdateSelectValue(obj));
document.querySelector(' .cpe-dropdown.cpe-select:focus-within').removeEventListener('click',UpdateSelectValue);
}
function UpdateSelectValue(obj) { // Saves the chosen value and content from the dropdown list into the select input
var content = obj.innerText;
var value = obj.getAttribute("value");
document.querySelector('.cpe-select:focus-within .cpe-select__value').setAttribute("value", value);
document.querySelector('.cpe-select:focus-within .cpe-select__value').innerHTML= content;
}
function HandleSelectInputBlurring() { // Handles Blurring
setTimeout(
(function() { document.querySelector(' .cpe-dropdown.cpe-select:focus-within').blur(); document.querySelector('.focus-overlay').focus(); } )
,0)
}
/* Range Inputs */
function UpdateRange() {
var ranges = document.querySelectorAll('input[type="range"]');
ranges.forEach(function(x) {
x.style.setProperty("--range-percent", (( ((x.value) - x.getAttribute('min') ) * 100) / (x.getAttribute('max') - x.getAttribute('min')) ) + '%' );
});
var progresses = document.querySelectorAll('progress');
progresses.forEach(function(x) {
x.style.setProperty("--range-percent", (( ((x.getAttribute('value')) - 0 ) * 100) / (x.getAttribute('max') - 0) ) + '%' );
});
}
function UpdateRangeInputs() {
UpdateRange();
var ranges2 = document.querySelectorAll('input[type="range"]');
ranges2.forEach(function(x) {
x.addEventListener("input", function(e) { UpdateRange(); });
});
}
/* Enable New Global Navigation - No exception for now */
(function () {
AliasFandomComponents();
UpdateRangeInputs();
DropDownUpdate();
/* DITTO */
document.querySelector("body").addEventListener("mouseenter", ( function(e) { CheckTheme(); } ) );
document.querySelector("body").addEventListener("mouseleave", ( function(e) { DropDownUpdate(); CheckTheme(); } ) );
document.querySelector("body").addEventListener("blur", ( function(e) { UpdateThemeColorMetaTag(); } ) );
document.querySelector("body").addEventListener("focus", ( function(e) { UpdateThemeColorMetaTag(); } ) );
/* END DITTO */
})();
/* Aliases all components with the .wds prefix to the ones from .cpe ones */
function AliasFandomComponents() {
var highlightedItems = document.querySelectorAll(":not(svg)[class*='wds-'], [class*='cpe-is-'], [class*='cpe-has-']");
while (document.querySelectorAll(':not(svg)[class*="wds-"], [class*="cpe-is-"], [class*="cpe-has-"]').length > 0) {
highlightedItems.forEach(function(x) {
/* WDS => CPE */
x.className = x.className.replace("wds-is-", "is-");
x.className = x.className.replace("wds-has-", "has-");
x.className = x.className.replace("wds-midlight-aqua", "cpe-midlight-color");
if (x.classList.contains('wds-open-to-right')) {
x.classList.remove("wds-open-to-right");
x.setAttribute("cpe-orient","land");
}
if (x.classList.contains('wds-dropdown')) {
x.setAttribute("tabindex","-1");
}
x.className = x.className.replace("wds-", "cpe-");
/* Legacy CPE => Modern CPE */
x.className = x.className.replace("cpe-is-", "is-");
x.className = x.className.replace("cpe-has-", "has-");
x.className = x.className.replace("cpe-dropdown-level-2", "cpe-dropdown-level-nested");
});
}
}
/* Banners */
function RemoveBanner() {
var banner= document.querySelector('#floatingbanner .cpe-banner-notification:focus-within');
banner.classList.add("is-transparent")
setTimeout(
(function () {
banner.remove();
if (!(document.querySelectorAll("#floatingbanner .cpe-banner-notification").length)) {
document.querySelector('#floatingbanner').remove();
}
document.querySelector('.focus-overlay').focus();
}),405);
}
function RemoveBanners() {
var banners = document.querySelectorAll('#floatingbanner .cpe-banner-notification');
banners.forEach(function(banner) {
banner.classList.add("is-transparent")
setTimeout(
(function () {
banner.remove();
if (!(document.querySelectorAll("#floatingbanner .cpe-banner-notification").length)) {
document.querySelector('#floatingbanner').remove();
}
document.querySelector('.focus-overlay').focus();
}),405);
});
}
function AddFloatingBanner(content='Sample Content',kind='message',extraclass='') {
if (kind === 'alert') {
var icon = 'report'
} else if (kind === 'pause') {
var icon = 'pause'
} else if (kind === 'warning') {
var icon = 'report_problem'
} else if (kind === 'success') {
var icon = 'done'
} else if (kind === 'progress') {
var icon = 'pending'
} else {
var icon = 'info'
}
var nogap = false;
if (!(document.querySelector(".top-gap #floatingbanner"))) {
var nogap = true;
document.querySelector(".top-gap").insertAdjacentHTML('afterbegin',
'<div class="cpe-banner-notification__container" id="floatingbanner" style="pointer-events:none;">' +
'<div style="display:flex; flex-flow:column;"><button style="pointer-events:auto; align-self:flex-end; margin-right:8.5px;" class="cpe-button" onclick="RemoveBanners()">Clear all</button></div>' +
'\n<div class="banners" style="pointer-events:auto;"></div></div>'
);
}
document.querySelector(".top-gap #floatingbanner .banners").insertAdjacentHTML('beforeend',
'<div class=" cpe-banner-notification is-transparent is-' + kind + '" id="' + extraclass + '">' +
'<div class="cpe-banner-notification__icon">' +
'<span class="cpe-icon cpe-icon-small material-icons">' +
icon +
'</span>' +
'</div>' +
'<span class="cpe-banner-notification__text">' + content + '</span>' +
'<span tabindex="-1" onclick="RemoveBanner()" class="cpe-banner-notification__close">' +
'<span class="cpe-icon cpe-icon-tiny cpe-icon-large material-icons">close</span>' +
'</span>' +
'</div>'
);
setTimeout(
(function () {
document.querySelector(".top-gap #floatingbanner .banners .cpe-banner-notification.is-transparent").classList.remove("is-transparent")
}),0);
}