Clock/update.js
MeowcaTheoRange b05d53025c
Use Fetch API
2022-09-14 09:44:56 -05:00

34 lines
No EOL
815 B
JavaScript

var prevSha = localStorage.getItem("commitsha") ?? "ThisShouldntBeASHA";
setInterval(reqData, 60000);
//balls lmao
function reqData() {
var donedata = (e) => {
var resp = e;
if (event.target.status.toString().includes("40")) {
console.log(event.target.status + " error :[")
return;
}
if (resp != prevSha) {
if (prevSha == "ThisShouldntBeASHA") {
localStorage.setItem("commitsha", resp);
} else {
document.querySelector(".scr-update--").classList.add("open");
setTimeout(() => {
window.location.href = window.location.href;
}, 15000);
localStorage.setItem("commitsha", resp);
}
}
};
fetch("https://ClockCheckGithub.meowcatheorange.repl.co")
.then(x => x.text())
.then(y => donedata(y));
}
reqData();