Alright, made requests authenticated with middleman
This commit is contained in:
parent
0a427f1e00
commit
8198300fa6
1 changed files with 10 additions and 5 deletions
15
update.js
15
update.js
|
@ -6,17 +6,22 @@ function reqData() {
|
|||
const XHR = new XMLHttpRequest();
|
||||
|
||||
XHR.addEventListener("load", (event) => {
|
||||
var resp = JSON.parse(event.target.response);
|
||||
var resp = event.target.response;
|
||||
|
||||
if (resp.sha != prevSha) {
|
||||
if (event.target.status.toString().includes("40")) {
|
||||
console.log(event.target.status + " error :[")
|
||||
return;
|
||||
}
|
||||
|
||||
if (resp != prevSha) {
|
||||
if (prevSha == "ThisShouldntBeASHA") {
|
||||
localStorage.setItem("commitsha", resp.sha);
|
||||
localStorage.setItem("commitsha", resp);
|
||||
} else {
|
||||
document.querySelector(".scr-update--").classList.add("open");
|
||||
setTimeout(() => {
|
||||
window.location.href = window.location.href;
|
||||
}, 15000);
|
||||
localStorage.setItem("commitsha", resp.sha);
|
||||
localStorage.setItem("commitsha", resp);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -25,7 +30,7 @@ function reqData() {
|
|||
console.log('Oops! Something went wrong.');
|
||||
});
|
||||
|
||||
XHR.open("GET", "https://api.github.com/repos/meowcatheorange/clock/commits/master");
|
||||
XHR.open("GET", "https://ClockCheckGithub.meowcatheorange.repl.co");
|
||||
|
||||
XHR.send();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue