Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
3kh0
GitHub Repository: 3kh0/3kh0.github.io-replit
Path: blob/main/js/home.js
617 views
1
var splashCacheAll;
2
var splashCache;
3
4
async function randomSay() {
5
if (splashCache) {
6
if (!splashCache.length) {
7
splashCache = splashCacheAll;
8
}
9
var says = splashCache;
10
} else {
11
var say = await fetch(location.origin + "/assets/say.json");
12
var says = await say.json();
13
splashCacheAll = says;
14
splashCache = says;
15
}
16
17
var getRandomSay = says[Math.floor(Math.random() * says.length)];
18
19
splashCache = splashCache.filter((splash) => splash !== getRandomSay);
20
21
return getRandomSay;
22
}
23
24
async function setRandomSay() {
25
var randomSplash = await randomSay();
26
if (randomSplash == "%REAL_IP%") {
27
var ips = await getIPs();
28
if (ips[0]) {
29
randomSplash = "Your real IP is " + ips[0];
30
} else {
31
randomSplash = "Cannot get your real IP :(";
32
}
33
} else if (randomSplash == "%GAMES_NUMBER%") {
34
var gamesFetch = await fetch(location.origin + "/assets/games.json");
35
var games = await gamesFetch.json();
36
randomSplash = "There are " + games.length + " games currently";
37
} else if (randomSplash == "%SPLASH_NUMBER%") {
38
randomSplash = "There are " + splashCacheAll.length + " of these messages!";
39
}
40
41
document.querySelector(".message").innerText = randomSplash;
42
}
43
44
if (document.querySelector(".message")) {
45
setRandomSay();
46
}
47