From 59cfed7dbdef7ae49a5d3a378475ddbaca11b358 Mon Sep 17 00:00:00 2001 From: Sky Date: Fri, 11 Aug 2023 16:45:51 -0400 Subject: [PATCH] clean up code a little bit - preparing for school to start --- index.html | 67 ++++++++++++++++++++++++++++++------------------------ js/all.js | 37 ++++++++++++++++++++---------- js/main.js | 7 +++--- 3 files changed, 65 insertions(+), 46 deletions(-) diff --git a/index.html b/index.html index 19ca90c9..08151091 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,7 @@ + - - + + + + + + + + + + + + + + - - - - - + Selenite - + - - + + - - - - - - + - - - + +
diff --git a/js/all.js b/js/all.js index e666e97e..2b569df7 100644 --- a/js/all.js +++ b/js/all.js @@ -1,6 +1,5 @@ function setCloak() { var tabicon = getCookie("tabicon"); - if (tabicon) { var link = document.querySelector("link[rel~='icon']"); if (link) { @@ -21,6 +20,7 @@ function setCloak() { if (tabname) { document.title = tabname; } + panicMode(); } function getCookie(cname) { let name = cname + "="; @@ -43,9 +43,6 @@ function panicMode() { if (panicurl == "") { panicurl = "https://google.com"; } - if ($("#panicmode").length > 0) { - $("#panicmode").prop({ href: panicurl }); - } const pressed = []; const secretCode = "safemode"; window.addEventListener("keyup", (e) => { @@ -56,13 +53,29 @@ function panicMode() { } }); } -document.addEventListener("DOMContentLoaded", function () { - let jquery_loader = document.createElement("script"); - jquery_loader.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"); - jquery_loader.async = false; - document.body.appendChild(jquery_loader); - window.addEventListener("load", function () { - panicMode(); - }); + +window.onload = function() { setCloak(); + if (!window.jQuery) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js'; + head.appendChild(script); + } +} + +defer(function () { + panicMode(); }); + + +function defer(method) { + if (window.jQuery) { + console.log("jquery found."); + panicMode(); + } else { + setTimeout(function() { defer(method) }, 50); + console.log("jquery not found, adding jquery."); + } +} diff --git a/js/main.js b/js/main.js index c96f63dd..78527497 100644 --- a/js/main.js +++ b/js/main.js @@ -4,10 +4,9 @@ function check() { clearInterval(interval); const body = document.querySelector("body"); body.style.removeProperty("display"); - const html = document.querySelector("body"); - html.style.removeProperty("background-color"); - const bar = document.querySelector("progress"); - bar.remove(); + } + if ($("#panicmode").length > 0) { + $("#panicmode").prop({ href: panicurl }); } }