-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlatest.html
More file actions
41 lines (38 loc) · 1.57 KB
/
latest.html
File metadata and controls
41 lines (38 loc) · 1.57 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MCSR Rules Redirect</title>
<meta name="description" content="The latest PDF release of the Minecraft Speedrunning ruleset.">
<link rel="icon" type="image/png" sizes="128x128" href="assets/favicon.png"> <!-- website icon -->
<script>
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("js").remove()
fetch("https://api.github.com/repos/Minecraft-Java-Edition-Speedrunning/rules/contents/pub/pdf")
.then(res => {
if (!res.ok) {
document.getElementById("js").innerText = "github api failed :("
throw new Error("http error status: " + response.status);
}
return res.json();
})
.then(data => {
data.sort((a, b) => {
a = a.name; b = b.name;
b1 = !a.includes("beta"); b2 = !b.includes("beta")
if (b1 ^ b2) return b2 - b1 // boolean subtraction
return b.split(".")[0].split("_").at(-1).substring(1) - a.split(".")[0].split("_").at(-1).substring(1) // string subtraction
})
pdf_url = "https://rawcdn.githack.com/Minecraft-Java-Edition-Speedrunning/rules/main/pub/pdf/" + data[0].name
link = document.getElementById("githack")
link.href = link.innerText = pdf_url
window.location.replace(pdf_url)
})
})
</script>
</head>
<body>
<h2 id="js">This site requires JavaScript!</h2>
<p>Redirecting to: <a id="githack">loading</a></p>
</body>
</html>