Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
FogNetwork
GitHub Repository: FogNetwork/Tsunami
Path: blob/main/public/js/index.js
1036 views
1
// _____ _ _ _ _
2
// | ___|__ __ _ | \ | | ___| |___ _____ _ __| | __
3
// | |_ / _ \ / _` | | \| |/ _ \ __\ \ /\ / / _ \| '__| |/ /
4
// | _| (_) | (_| | | |\ | __/ |_ \ V V / (_) | | | <
5
// |_| \___/ \__, | |_| \_|\___|\__| \_/\_/ \___/|_| |_|\_\
6
// |___/
7
8
var appearance = localStorage.getItem("appearance")
9
10
if (localStorage.hasOwnProperty("appearance")) {
11
document.getElementsByTagName("body")[0].setAttribute("appearance", appearance)
12
setLogo(getComputedStyle(document.body).getPropertyValue('--highlight').replaceAll(" ", ""))
13
} else {
14
localStorage.setItem("appearance", "default")
15
document.getElementsByTagName("body")[0].setAttribute("appearance", "default")
16
}
17
18
console.log("%cTsunami", "color: " + getComputedStyle(document.body).getPropertyValue('--highlight').replaceAll(" ", "") + "; font-size: 45px")
19
console.log("%cBy Fog Network", "color: " + getComputedStyle(document.body).getPropertyValue('--highlight').replaceAll(" ", "") + "; font-size: 20px")
20
console.log("%chttps://discord.gg/yk33HZSZkU", "font-size: 15px")
21
console.log("%chttps://github.com/FogNetwork/Tsunami", "font-size: 15px")
22
23
var title = localStorage.getItem("title")
24
var favicon = localStorage.getItem("favicon")
25
26
if (localStorage.hasOwnProperty("title")) {
27
document.title = title
28
}
29
30
if (localStorage.hasOwnProperty("favicon")) {
31
document.querySelector("link[rel='shortcut icon']").href = favicon;
32
}
33
34
function settitle(title) {
35
if (title !== "") {
36
localStorage.setItem("title", title)
37
document.title = title
38
} else {
39
localStorage.removeItem("title")
40
document.title = "Settings"
41
}
42
}
43
44
function setfavicon(icon, noproxy) {
45
if (icon !== "") {
46
if (!noproxy) {
47
icon = "/corrosion/gateway?url=" + icon
48
}
49
localStorage.setItem("favicon", icon)
50
document.querySelector("link[rel='shortcut icon']").href = icon;
51
} else {
52
localStorage.removeItem("favicon")
53
setLogo(getComputedStyle(document.body).getPropertyValue('--highlight').replaceAll(" ", ""))
54
}
55
}
56
57
function setgoogle() {
58
settitle("Google")
59
setfavicon("https://www.google.com/favicon.ico")
60
}
61
62
function setgoogled() {
63
settitle("Google Drive")
64
setfavicon("https://www.drive.google.com/favicon.ico")
65
}
66
67
function setedpuzzle() {
68
settitle("Edpuzzle")
69
setfavicon("https://edpuzzle.imgix.net/favicons/favicon-32.png")
70
}
71
72
function setzoom() {
73
settitle("Zoom")
74
setfavicon("https://st1.zoom.us/zoom.ico")
75
}
76
77
function setreset() {
78
localStorage.removeItem("title")
79
localStorage.removeItem("favicon")
80
document.title = "Settings"
81
setLogo(getComputedStyle(document.body).getPropertyValue('--highlight').replaceAll(" ", ""))
82
document.getElementById("cloaktitletitle").value = ""
83
document.getElementById("cloaktitleicon").value = ""
84
document.getElementById("cloaktitleurl").value = ""
85
}
86
87
async function setTabByURL(url) {
88
if (url == null || url == "") {
89
return setreset();
90
}
91
var title = url;
92
var favicon = "data:,"
93
var site = await fetch("/rhodium/gateway?url=" + url)
94
var code = await site.text()
95
var parser = new DOMParser();
96
var doc = parser.parseFromString(code, "text/html");
97
if (doc.getElementsByTagName("title")[0]) {
98
title = doc.getElementsByTagName("title")[0].innerText
99
}
100
if (doc.querySelector("link[rel='shortcut icon']")) {
101
favicon = doc.querySelector("link[rel='shortcut icon']").href
102
}
103
if (doc.querySelector("link[rel='icon']")) {
104
favicon = doc.querySelector("link[rel='icon']").href
105
}
106
settitle(title)
107
setfavicon(favicon, true)
108
}
109
110
var info = document.getElementById("info")
111
var isinfo = "no"
112
113
function goinfo() {
114
if (isinfo == "no") {
115
document.getElementById("info").style.display = "flex"
116
isinfo = "yes"
117
} else {
118
document.getElementById("info").style.display = "none"
119
isinfo = "no"
120
}
121
}
122
123
if (localStorage.getItem("search") == null) {
124
localStorage.setItem("search", "Google")
125
}
126
127
var css = localStorage.getItem("css")
128
129
if (css !== null) {
130
var csselm = document.createElement("style")
131
csselm.innerText = css
132
document.body.appendChild(csselm)
133
}
134
135
if ('serviceWorker' in navigator) {
136
navigator.serviceWorker.register(window.location.origin + "/sw.js");
137
}
138
139
function getLogo(highlight = "#2493ff") {
140
var logoCode = `<svg version="1.1" viewBox="0.0 0.0 500.0 500.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="p.0"><path d="m0 0l500.0 0l0 500.0l-500.0 0l0 -500.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#p.0)"><path fill="#000000" fill-opacity="0.0" d="m0 0l500.0 0l0 500.0l-500.0 0z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m31.11811 250.0l0 0c0 -120.88513 97.99676 -218.8819 218.8819 -218.8819l0 0c58.051086 0 113.72455 23.060703 154.77286 64.109024c41.04834 41.048317 64.10904 96.72178 64.10904 154.77286l0 0c0 120.88513 -97.996765 218.8819 -218.8819 218.8819l0 0c-120.88513 0 -218.8819 -97.996765 -218.8819 -218.8819z" fill-rule="evenodd"/><path stroke="%HIGHLIGHT%" stroke-width="24.0" stroke-linejoin="round" stroke-linecap="butt" d="m31.11811 250.0l0 0c0 -120.88513 97.99676 -218.8819 218.8819 -218.8819l0 0c58.051086 0 113.72455 23.060703 154.77286 64.109024c41.04834 41.048317 64.10904 96.72178 64.10904 154.77286l0 0c0 120.88513 -97.996765 218.8819 -218.8819 218.8819l0 0c-120.88513 0 -218.8819 -97.996765 -218.8819 -218.8819z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m50.7455 250.00534l0 0c0 -110.04817 89.21167 -199.25984 199.25984 -199.25984l0 0c52.846985 0 103.52951 20.993385 140.89798 58.361855c37.36847 37.368477 58.361877 88.05099 58.361877 140.89798l0 0c0 110.04819 -89.21167 199.25986 -199.25986 199.25986l0 0c-110.04817 0 -199.25984 -89.21167 -199.25984 -199.25986z" fill-rule="evenodd"/><path stroke="%HIGHLIGHT%" stroke-width="24.0" stroke-linejoin="round" stroke-linecap="butt" d="m50.7455 250.00534l0 0c0 -110.04817 89.21167 -199.25984 199.25984 -199.25984l0 0c52.846985 0 103.52951 20.993385 140.89798 58.361855c37.36847 37.368477 58.361877 88.05099 58.361877 140.89798l0 0c0 110.04819 -89.21167 199.25986 -199.25986 199.25986l0 0c-110.04817 0 -199.25984 -89.21167 -199.25984 -199.25986z" fill-rule="evenodd"/><path fill="%HIGHLIGHT%" d="m282.27924 123.177414c-2.1687012 -2.4584656 -5.3442993 -1.2292328 -9.75946 2.7657776c-4.4151917 3.9950104 -9.450439 8.989075 -16.731552 21.2043c-7.2811127 12.215225 -19.674255 40.793945 -26.955185 52.08705c-7.2809143 11.293106 -6.583267 13.904633 -16.730347 15.67157c-10.147064 1.766922 -29.125076 -2.2275085 -44.15207 -5.0700073c-15.027008 -2.842514 -36.172928 -10.294846 -46.009956 -11.985031c-9.8370285 -1.6902008 -11.230736 -0.614624 -13.01223 1.8438416c-1.7815018 2.4584656 -1.0848465 7.990219 2.323227 12.906967c3.408081 4.916748 7.7458878 9.756165 18.125244 16.59349c10.379349 6.837326 34.546143 18.20755 44.150894 24.43045c9.604736 6.2229004 11.153763 8.066956 13.477585 12.906952c2.323822 4.840027 3.641159 8.758118 0.46536255 16.133118c-3.1757965 7.3750305 -14.79512 21.43332 -19.520126 28.116974c-4.7250214 6.6836853 -6.196472 7.5290833 -8.829941 11.985046c-2.633484 4.4559937 -5.189392 9.373108 -6.970886 14.750824c-1.7814941 5.3776855 -3.7181244 11.753662 -3.7181244 17.515411c0 5.7617493 1.3945007 14.519836 3.7181244 17.055054c2.3236237 2.5351868 3.6397705 4.071533 10.223648 -1.8438721c6.5838623 -5.9153748 20.681732 -24.967346 29.279587 -33.64853c8.597855 -8.681183 15.026413 -14.289856 22.30754 -18.438507c7.2811127 -4.1486816 14.330353 -7.1450195 21.37918 -6.453491c7.0488434 0.69155884 12.393539 2.9971313 20.913818 10.602753c8.520294 7.605591 21.997498 26.58023 30.207947 35.030823c8.210449 8.450592 13.322876 12.215607 19.05478 15.6727295c5.731903 3.4571228 11.851013 5.2236633 15.336639 5.0700073c3.4856567 -0.153656 5.034851 -1.9203796 5.577179 -5.991913c0.5423279 -4.0715637 -0.8515625 -12.521942 -2.3232117 -18.437347c-1.4716797 -5.9154053 -2.013977 -5.9154053 -6.506714 -17.055054c-4.492737 -11.139648 -16.809113 -39.48819 -20.449677 -49.782806c-3.6405334 -10.294647 -3.4076538 -8.374268 -1.3936768 -11.985046c2.013977 -3.6107788 0.38720703 -5.3007812 13.47757 -9.679626c13.090393 -4.3788757 51.509583 -12.675415 65.06473 -16.593506c13.555145 -3.9180908 13.787445 -4.533493 16.266174 -6.915039c2.4787598 -2.3815308 1.6271667 -4.83902 -1.3937073 -7.374222c-3.020874 -2.535202 -7.35907 -6.2234955 -16.731537 -7.83696c-9.372437 -1.6134644 -28.426819 -1.8438568 -39.503235 -1.8438568c-11.0763855 0 -19.364197 1.920578 -26.95517 1.8438568c-7.590973 -0.07673645 -13.788239 -0.8446045 -18.590607 -2.3042297c-4.802368 -1.45961 -8.054932 -2.765976 -10.223633 -6.453476c-2.1687012 -3.6875153 -4.182678 -2.841919 -2.7886047 -15.67157c1.394104 -12.829651 9.836456 -48.16916 11.153168 -61.306305c1.316742 -13.137154 -1.0840454 -15.058128 -3.2527466 -17.516602z" fill-rule="evenodd"/><path stroke="%HIGHLIGHT%" stroke-width="24.0" stroke-linejoin="round" stroke-linecap="butt" d="m282.27924 123.177414c-2.1687012 -2.4584656 -5.3442993 -1.2292328 -9.75946 2.7657776c-4.4151917 3.9950104 -9.450439 8.989075 -16.731552 21.2043c-7.2811127 12.215225 -19.674255 40.793945 -26.955185 52.08705c-7.2809143 11.293106 -6.583267 13.904633 -16.730347 15.67157c-10.147064 1.766922 -29.125076 -2.2275085 -44.15207 -5.0700073c-15.027008 -2.842514 -36.172928 -10.294846 -46.009956 -11.985031c-9.8370285 -1.6902008 -11.230736 -0.614624 -13.01223 1.8438416c-1.7815018 2.4584656 -1.0848465 7.990219 2.323227 12.906967c3.408081 4.916748 7.7458878 9.756165 18.125244 16.59349c10.379349 6.837326 34.546143 18.20755 44.150894 24.43045c9.604736 6.2229004 11.153763 8.066956 13.477585 12.906952c2.323822 4.840027 3.641159 8.758118 0.46536255 16.133118c-3.1757965 7.3750305 -14.79512 21.43332 -19.520126 28.116974c-4.7250214 6.6836853 -6.196472 7.5290833 -8.829941 11.985046c-2.633484 4.4559937 -5.189392 9.373108 -6.970886 14.750824c-1.7814941 5.3776855 -3.7181244 11.753662 -3.7181244 17.515411c0 5.7617493 1.3945007 14.519836 3.7181244 17.055054c2.3236237 2.5351868 3.6397705 4.071533 10.223648 -1.8438721c6.5838623 -5.9153748 20.681732 -24.967346 29.279587 -33.64853c8.597855 -8.681183 15.026413 -14.289856 22.30754 -18.438507c7.2811127 -4.1486816 14.330353 -7.1450195 21.37918 -6.453491c7.0488434 0.69155884 12.393539 2.9971313 20.913818 10.602753c8.520294 7.605591 21.997498 26.58023 30.207947 35.030823c8.210449 8.450592 13.322876 12.215607 19.05478 15.6727295c5.731903 3.4571228 11.851013 5.2236633 15.336639 5.0700073c3.4856567 -0.153656 5.034851 -1.9203796 5.577179 -5.991913c0.5423279 -4.0715637 -0.8515625 -12.521942 -2.3232117 -18.437347c-1.4716797 -5.9154053 -2.013977 -5.9154053 -6.506714 -17.055054c-4.492737 -11.139648 -16.809113 -39.48819 -20.449677 -49.782806c-3.6405334 -10.294647 -3.4076538 -8.374268 -1.3936768 -11.985046c2.013977 -3.6107788 0.38720703 -5.3007812 13.47757 -9.679626c13.090393 -4.3788757 51.509583 -12.675415 65.06473 -16.593506c13.555145 -3.9180908 13.787445 -4.533493 16.266174 -6.915039c2.4787598 -2.3815308 1.6271667 -4.83902 -1.3937073 -7.374222c-3.020874 -2.535202 -7.35907 -6.2234955 -16.731537 -7.83696c-9.372437 -1.6134644 -28.426819 -1.8438568 -39.503235 -1.8438568c-11.0763855 0 -19.364197 1.920578 -26.95517 1.8438568c-7.590973 -0.07673645 -13.788239 -0.8446045 -18.590607 -2.3042297c-4.802368 -1.45961 -8.054932 -2.765976 -10.223633 -6.453476c-2.1687012 -3.6875153 -4.182678 -2.841919 -2.7886047 -15.67157c1.394104 -12.829651 9.836456 -48.16916 11.153168 -61.306305c1.316742 -13.137154 -1.0840454 -15.058128 -3.2527466 -17.516602z" fill-rule="evenodd"/></g></svg>`
141
logoCode = logoCode.replaceAll("%HIGHLIGHT%", highlight)
142
logoCode = "data:image/svg+xml;base64," + window.btoa(logoCode)
143
return logoCode;
144
}
145
146
function setLogo(highlight) {
147
document.querySelector("link[rel='shortcut icon']").href = getLogo(highlight)
148
}
149
150
var installApp
151
152
window.addEventListener('beforeinstallprompt', function (e) {
153
e.preventDefault();
154
installApp = e;
155
});
156
157
function createBox() {
158
let span = document.createElement('span');
159
span.classList.add('animated-box');
160
let size = Math.random() * 80;
161
span.style.height = 40 + size + 'px';
162
span.style.width = 40 + size + 'px';
163
span.style.top = ((1.3 * Math.random()) * innerHeight) + 'px';
164
span.style.left = ((Math.random()) * (innerWidth)) + 'px';
165
166
document.querySelector('#squares').appendChild(span);
167
168
setTimeout(() => {
169
span.remove();
170
}, 6000)
171
}
172
173
function loadSquares() {
174
if (window.squareInt) return;
175
if (window.pJSDom[0]) {
176
window.pJSDom[0].pJS.fn.vendors.destroypJS();
177
window["pJSDom"] = [];
178
}
179
window.squareInt = setInterval(createBox, 300);
180
}
181
182
function destroySquares() {
183
clearInterval(window.squareInt);
184
window.squareInt = null;
185
document.querySelector('#squares').innerHTML = ""
186
}
187
188
function destroyParticles() {
189
if (!window.pJSDom[0]) return;
190
window.pJSDom[0].pJS.fn.vendors.destroypJS();
191
window["pJSDom"] = [];
192
}
193
194
function loadParticles() {
195
destroySquares()
196
destroyParticles()
197
particlesJS("particles-js", {
198
"particles": {
199
"number": {
200
"value": 80,
201
"density": {
202
"enable": true,
203
"value_area": 800
204
}
205
},
206
"color": {
207
"value": "#ffffff"
208
},
209
"shape": {
210
"type": "circle",
211
"stroke": {
212
"width": 0,
213
"color": "#000000"
214
},
215
"polygon": {
216
"nb_sides": 5
217
},
218
},
219
"opacity": {
220
"value": 1,
221
"random": true,
222
"anim": {
223
"enable": true,
224
"speed": 1,
225
"opacity_min": 0,
226
"sync": false
227
}
228
},
229
"size": {
230
"value": 3,
231
"random": true,
232
"anim": {
233
"enable": false,
234
"speed": 4,
235
"size_min": 0.3,
236
"sync": false
237
}
238
},
239
"line_linked": {
240
"enable": true,
241
"distance": 150,
242
"color": "#ffffff",
243
"opacity": 0.4,
244
"width": 1
245
},
246
"move": {
247
"enable": true,
248
"speed": 1,
249
"direction": "none",
250
"random": true,
251
"straight": false,
252
"out_mode": "out",
253
"bounce": false,
254
"attract": {
255
"enable": false,
256
"rotateX": 600,
257
"rotateY": 600
258
}
259
}
260
},
261
"interactivity": {
262
"detect_on": "canvas",
263
"events": {
264
"onhover": {
265
"enable": false,
266
"mode": "bubble"
267
},
268
"onclick": {
269
"enable": false,
270
"mode": "repulse"
271
},
272
"resize": true
273
},
274
"modes": {
275
"grab": {
276
"distance": 400,
277
"line_linked": {
278
"opacity": 1
279
}
280
},
281
"bubble": {
282
"distance": 250,
283
"size": 0,
284
"duration": 2,
285
"opacity": 0,
286
"speed": 3
287
},
288
"repulse": {
289
"distance": 400,
290
"duration": 0.4
291
},
292
"push": {
293
"particles_nb": 4
294
},
295
"remove": {
296
"particles_nb": 2
297
}
298
}
299
},
300
"retina_detect": true
301
});
302
}
303
304
function loadStars() {
305
destroySquares()
306
destroyParticles()
307
particlesJS("particles-js", {
308
"particles": {
309
"number": {
310
"value": 160,
311
"density": {
312
"enable": true,
313
"value_area": 800
314
}
315
},
316
"color": {
317
"value": "#ffffff"
318
},
319
"shape": {
320
"type": "circle",
321
"stroke": {
322
"width": 0,
323
"color": "#000000"
324
},
325
"polygon": {
326
"nb_sides": 5
327
},
328
},
329
"opacity": {
330
"value": 1,
331
"random": true,
332
"anim": {
333
"enable": true,
334
"speed": 1,
335
"opacity_min": 0,
336
"sync": false
337
}
338
},
339
"size": {
340
"value": 3,
341
"random": true,
342
"anim": {
343
"enable": false,
344
"speed": 4,
345
"size_min": 0.3,
346
"sync": false
347
}
348
},
349
"line_linked": {
350
"enable": false,
351
"distance": 150,
352
"color": "#ffffff",
353
"opacity": 0.4,
354
"width": 1
355
},
356
"move": {
357
"enable": true,
358
"speed": 1,
359
"direction": "none",
360
"random": true,
361
"straight": false,
362
"out_mode": "out",
363
"bounce": false,
364
"attract": {
365
"enable": false,
366
"rotateX": 600,
367
"rotateY": 600
368
}
369
}
370
},
371
"interactivity": {
372
"detect_on": "canvas",
373
"events": {
374
"onhover": {
375
"enable": false,
376
"mode": "bubble"
377
},
378
"onclick": {
379
"enable": false,
380
"mode": "repulse"
381
},
382
"resize": true
383
},
384
"modes": {
385
"grab": {
386
"distance": 400,
387
"line_linked": {
388
"opacity": 1
389
}
390
},
391
"bubble": {
392
"distance": 250,
393
"size": 0,
394
"duration": 2,
395
"opacity": 0,
396
"speed": 3
397
},
398
"repulse": {
399
"distance": 400,
400
"duration": 0.4
401
},
402
"push": {
403
"particles_nb": 4
404
},
405
"remove": {
406
"particles_nb": 2
407
}
408
}
409
},
410
"retina_detect": true
411
});
412
}
413
414
var background = localStorage.getItem("background") || ""
415
if (background == "particles") {
416
loadParticles()
417
} else if (background == "stars") {
418
loadStars()
419
} else if (background == "squares") {
420
loadSquares()
421
}
422