Clock/update.js

40 lines
967 B
JavaScript
Raw Normal View History

2022-09-13 15:57:56 +00:00
var prevSha = localStorage.getItem("commitsha") ?? "ThisShouldntBeASHA";
setInterval(reqData, 60000);
2022-09-13 15:57:56 +00:00
2022-09-13 18:13:11 +00:00
//balls lmao
2022-09-13 15:57:56 +00:00
function reqData() {
const XHR = new XMLHttpRequest();
XHR.addEventListener("load", (event) => {
var resp = event.target.response;
2022-09-13 15:57:56 +00:00
if (event.target.status.toString().includes("40")) {
console.log(event.target.status + " error :[")
return;
}
if (resp != prevSha) {
2022-09-13 15:57:56 +00:00
if (prevSha == "ThisShouldntBeASHA") {
localStorage.setItem("commitsha", resp);
2022-09-13 15:57:56 +00:00
} else {
document.querySelector(".scr-update--").classList.add("open");
setTimeout(() => {
window.location.href = window.location.href;
2022-09-13 16:07:07 +00:00
}, 15000);
localStorage.setItem("commitsha", resp);
2022-09-13 15:57:56 +00:00
}
}
});
XHR.addEventListener("error", (event) => {
console.log('Oops! Something went wrong.');
});
XHR.open("GET", "https://ClockCheckGithub.meowcatheorange.repl.co");
2022-09-13 15:57:56 +00:00
XHR.send();
}
reqData();