forked from 3kh0/3kh0.github.io-replit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.js
46 lines (39 loc) · 1.27 KB
/
home.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
var splashCacheAll;
var splashCache;
async function randomSay() {
if (splashCache) {
if (!splashCache.length) {
splashCache = splashCacheAll;
}
var says = splashCache;
} else {
var say = await fetch(location.origin + "/assets/say.json");
var says = await say.json();
splashCacheAll = says;
splashCache = says;
}
var getRandomSay = says[Math.floor(Math.random() * says.length)];
splashCache = splashCache.filter((splash) => splash !== getRandomSay);
return getRandomSay;
}
async function setRandomSay() {
var randomSplash = await randomSay();
if (randomSplash == "%REAL_IP%") {
var ips = await getIPs();
if (ips[0]) {
randomSplash = "Your real IP is " + ips[0];
} else {
randomSplash = "Cannot get your real IP :(";
}
} else if (randomSplash == "%GAMES_NUMBER%") {
var gamesFetch = await fetch(location.origin + "/assets/games.json");
var games = await gamesFetch.json();
randomSplash = "There are " + games.length + " games currently";
} else if (randomSplash == "%SPLASH_NUMBER%") {
randomSplash = "There are " + splashCacheAll.length + " of these messages!";
}
document.querySelector(".message").innerText = randomSplash;
}
if (document.querySelector(".message")) {
setRandomSay();
}