-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
99 lines (93 loc) · 2.73 KB
/
script.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
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
import "/ui.js";
import Popup from "https://gavinmorrow.github.io/EasyJS/2/ui/popup/index.js";
import cookies from "https://gavinmorrow.github.io/EasyJS/2/cookies/main.js";
import ili from "/js/ili.js";
import log from "https://gavinmorrow.com/bb/src/log.js";
cookies.cookieConsent();
const Cookie = cookies.Cookie;
window.passInfo = async () => {
const username = document.getElementById("username");
const pass = document.getElementById("pass");
if (username.value.toLowerCase() == "parzival") {
switch (pass.value) {
case "You have been recruited by the Star League to defend the frontier against Xur and the Ko-Dan Armanda.":
case "No one in the world gets what they want and that is beautiful.":
case "Reindeer Flotilla Setec Astronomy":
ee("rp1", true);
new Popup(
"Congratulations! You have discovered a Ready Player 1 easter egg!",
undefined,
undefined,
undefined,
true
)
.then(popup => popup.show())
.then(popup => popup.hide());
return;
default:
break;
}
}
const popupOptions = [2500, true];
const popup1 = new Popup(
`Hello ${username.value}`,
popupOptions[0],
false,
"in"
);
const popup2 = new Popup(
"Please enter the correct username and password.",
...popupOptions,
"error"
);
setTimeout(async () => {
// TODO: Remake login to account for PHP hashing (not JS)
if (await ili(username.value, pass.value)) {
log(username.value, "login");
const month = 1000 * 60 * 60 * 24 * 7 * 4;
new Cookie(
"username",
username.value,
new Date(Date.now() + month).toUTCString()
);
new Cookie(
"pass",
pass.value,
new Date(Date.now() + month).toUTCString()
);
popup1.wrapper.style.background = "black";
await (await popup1.show()).hide();
location.replace("/game/");
} else {
// Only log if the user exists, otherwise it will create an empty user directory (makeing a non-exisitant user)
if (
(await fetch(
`${bbSrc}/userExists.php?username=${username.value}`
).then(r => r.text())) === "1"
)
log(username.value, "login-attempt");
await (await popup2.show()).hide();
}
}, 100);
};
const passToggle = document.getElementById("pass-toggle");
passToggle.addEventListener("change", e => {
if (passToggle.checked) {
document.getElementById("pass").type = "text";
document.getElementById("pass-toggle-label").innerHTML =
"Hide Password";
} else {
document.getElementById("pass").type = "password";
document.getElementById("pass-toggle-label").innerHTML =
"Show Password";
}
});
addEventListener("load", () =>
passToggle.style.setProperty(
"--size",
getComputedStyle(document.getElementById("pass-toggle-label")).fontSize
)
);
(async () => {
if (await ili()) location.replace("/game/");
})();