From 8198300fa609538d25cb51a2b4188a2f266256b8 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange Date: Tue, 13 Sep 2022 11:24:16 -0500 Subject: [PATCH] Alright, made requests authenticated with middleman --- update.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/update.js b/update.js index 56cdabc..4ba16a0 100644 --- a/update.js +++ b/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(); }