-
Notifications
You must be signed in to change notification settings - Fork 5
/
minimum.html
109 lines (100 loc) · 4.15 KB
/
minimum.html
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
<!--
"Bare Minimum" example of brookeafk.com. All settings were removed. This code is to display a single event.
Could be useful for devs (or anyone else) wanting to understand my code. Created for the homepage of https://pit.wiki.
-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<link rel="shortcut icon" type="image/x-icon" href="favicon_icons/favicon.ico">
<link href="font/webfontkit-20220210-002804/stylesheet.css" type="text/css" rel="stylesheet">
<title>BrookeAFK Minimum Mode</title>
<script src="emergency.js?v=21"></script>
<script scr="control.js?v=0"></script>
<meta name="description" content="">
</head>
<body style="font-size: 16px; font-family: Roboto; color: #FFF">
<script>
var HiddenEventCount = 0;
var DoesStuffExist = false;
var offset = 0;
var speed = 0; // Only exists on minimum. Used to determine how fast the function should be called.
var counter = 0;
function MakeFunTimestamps(convertible) {
let currentTime = (Date.now() + offset);
if (convertible - currentTime <= 0) {
convertible = "Passed!"
}
if (convertible - currentTime <= 60000) {
convertible = (((Math.floor(((convertible - currentTime)*100))/100000).toFixed(2)) + "s");
} else if (convertible - currentTime <= 3600000) {
convertible = ((Math.floor(((convertible - currentTime))/60000) + "m " + (Math.floor(((convertible - currentTime))/1000) % 60) + "s"));
} else if (convertible - currentTime > 1) {
convertible = ((Math.floor(((convertible - currentTime))/3600000) + "h " + (Math.floor(((convertible - currentTime))/60000) % 60) + "m"));
}
return convertible;
}
function TimeOfDay(s) {
var offset = (new Date().getTimezoneOffset())*-60000;
return new Date(s + offset).toISOString().slice(-13, -8);
}
var emergency = true;
var pp_url = ""
if(emergency == false) {
pp_url = ('https://raw.githubusercontent.com/BrookeAFK/brookeafk-api/main/events.js'); //stands for "Pit Panda"
}
data_backup = MakeAPIAndHTML();
setInterval(getPitPanda,40);
async function MakeAPIAndHTML() { //Calls the API exactly once (thanks McPqndq for pointing out that i do not have to call apis more than once)
if(emergency == true) {
window.localStorage.clear(); //attempts to clear the local storage to allow reloading to work
localStorage.clear();
window.data = await window.emergency_data;
}
if(emergency == false) {
const response = await fetch(pp_url);
window.data = await response.json();
}
window.data_backup = window.data;
window.EventsToLoad = Object.keys(window.data).length;
var div = document.createElement("div");
div.id = ("event_0");
document.body.appendChild(div);
DoesStuffExist = true;
}
function RapidFirst(transformation) {
let currentTime = (Date.now() + offset);
if (DoesStuffExist == true) {
HasStuffLoaded = true;
document.getElementById('event_0').innerHTML = (`<span>` + transformation[HiddenEventCount].event + " in " + MakeFunTimestamps(transformation[HiddenEventCount].timestamp) + ` (` + TimeOfDay(transformation[HiddenEventCount].timestamp) + " local time)</span>");
console.log(transformation[HiddenEventCount].timestamp - currentTime)
if(((transformation[HiddenEventCount].timestamp - currentTime) < 0)) {
speed = 999;
} else if((transformation[HiddenEventCount].timestamp - currentTime) > 60000) {
speed = 0;
} else {
speed = 1;
}
if(MakeFunTimestamps(transformation[HiddenEventCount].timestamp) == "Passed!" && !!document.getElementById('event_0') == true) {
window.HiddenEventCount = window.HiddenEventCount + 1;
}}}
function getPitPanda() {
if(speed == 0) {
counter += 1;
if(counter == 5) {
counter = 0;
RapidFirst(window.data);
}
} else if(speed == 1) {
RapidFirst(window.data);
} else if(speed == 999) {
for(i = 0; i < 10; i++) {
RapidFirst(window.data);
}
}
}
</script>
</body>
</html>