forked from XYZABCEFG/y8slope
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.js
More file actions
111 lines (91 loc) · 2.68 KB
/
lib.js
File metadata and controls
111 lines (91 loc) · 2.68 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
window.BrowserDetector = (function() {
function detect() {
var ua = navigator.userAgent;
var tem;
var M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+\.\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+\.\d+)/g.exec(ua) || [];
return {
name: 'Internet Explorer',
version: (tem[1] || '')
};
}
if (/(coc_coc_browser|edge(?=\/))\/?\s*(\d+\.\d+)/i.test(ua)) {
tem = ua.match(/(coc_coc_browser|edge(?=\/))\/?\s*(\d+)\.\d+/i);
if (tem != null) {
return {
name: (tem[1] == 'Edge' ? tem[1] : 'CocCoc'),
version: tem[2]
};
}
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR\/(\d+\.\d+)/);
if (tem != null) {
return {
name: 'Opera',
version: tem[1]
};
}
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+\.\d+)/i)) != null) {
M.splice(1, 1, tem[1]);
}
if (M[0] == 'MSIE') {
M[0] = 'Internet Explorer';
}
return {
name: M[0],
version: M[1]
};
}
var detect = detect();
return {
name: detect.name,
version: detect.version,
msie: (detect.name == 'Internet Explorer'),
msedge: (detect.name == 'Edge'),
coccoc: (detect.name == 'CocCoc'),
firefox: (detect.name == 'Firefox'),
safari: (detect.name == 'Safari'),
chrome: (detect.name == 'Chrome'),
opera: (detect.name == 'Opera'),
};
})();
// Leaving just for page to not throw error on body click
function enableSound() {
return;
}
!function() {
if (!(BrowserDetector.chrome && BrowserDetector.version >= 66)) {
return;
}
function buildSoundOverlay() {
const overlay = document.createElement('div');
overlay.classList.add('sound-overlay');
overlay.setAttribute('id', 'sound-overlay');
return overlay;
}
function buildSoundText() {
const textNode = document.createTextNode('Click here to enable sound');
const textSpan = document.createElement('span');
textSpan.classList.add('sound-text');
textSpan.appendChild(textNode);
return textSpan;
}
const soundOverlay = buildSoundOverlay();
soundOverlay.appendChild(buildSoundText());
document.addEventListener('DOMContentLoaded', function() {
var root = document.getElementsByClassName('webgl-content')[0];
if (!root) {
root = document.getElementsByClassName('template-wrap')[0];
}
root.appendChild(soundOverlay);
});
'click removeSoundOverlay'
.split(' ')
.forEach(e => document.addEventListener(e, function() {
soundOverlay.style.display = 'none';
}, false));
}();