From 56243891ebdb2511512757d27bd83e0c63072b43 Mon Sep 17 00:00:00 2001 From: limepotato Date: Sun, 8 Sep 2024 14:14:28 -0600 Subject: [PATCH] simplify --- public/scripts/fuckchrome.js | 19 ------- public/scripts/lastfm.js | 8 --- public/scripts/main.js | 62 +++++++++++++++++---- src/components/scripts/normal-scripts.astro | 3 - src/layouts/Layout.astro | 4 +- 5 files changed, 52 insertions(+), 44 deletions(-) delete mode 100644 public/scripts/fuckchrome.js delete mode 100644 public/scripts/lastfm.js diff --git a/public/scripts/fuckchrome.js b/public/scripts/fuckchrome.js deleted file mode 100644 index 6452e77..0000000 --- a/public/scripts/fuckchrome.js +++ /dev/null @@ -1,19 +0,0 @@ -function redirect() { - const chromium = /Chrome|Chromium|OPR|Opera|Edge|UC|QQ/.test( - navigator.userAgent - ); - - if (navigator.brave) { - window.location.replace("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); - } - if (!navigator.brave) { - if (!localStorage.getItem("disclaimerAccepted")) { - if (chromium && screen.width >= 699) { - window.location.replace("/bsod"); - } - if (chromium && screen.width <= 699) { - window.location.replace("/mobile-warn"); - } - } - } -} diff --git a/public/scripts/lastfm.js b/public/scripts/lastfm.js deleted file mode 100644 index 09a3f51..0000000 --- a/public/scripts/lastfm.js +++ /dev/null @@ -1,8 +0,0 @@ -const user = "limepotato"; -const url = `https://lastfm-last-played.biancarosa.com.br/${user}/latest-song`; -const song = document.querySelector("#song"); -fetch(url) - .then((response) => response.json()) - .then((json) => { - song.innerHTML = `${json.track.name} - ${json.track.artist["#text"]}`; - }); diff --git a/public/scripts/main.js b/public/scripts/main.js index 4699a9a..bc18609 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -1,14 +1,54 @@ +// loads all the functions to be loaded on load, pretty simple, it loads shit on load. +function onLoad() { + jsEnabled(); + getSGAState(); + redirect(); + checkBoxes(); + getPlaceholder(); +} + // if javascript is enabled, this script will load, enabling all site elements that use javascript, by default these are all hidden. function jsEnabled() { - // Get JS required element ids - const lastFmWidget = document.getElementById("lastfm-widget"); - const ntfyWidgetContainer = document.getElementById("ntfyWidgetContainer"); - const sgaButton = document.getElementById("sgaButton"); - const incrementButton = document.getElementById("incrementButton"); + // Get JS required element ids + const lastFmWidget = document.getElementById("lastfm-widget"); + const ntfyWidgetContainer = document.getElementById("ntfyWidgetContainer"); + const sgaButton = document.getElementById("sgaButton"); + const incrementButton = document.getElementById("incrementButton"); - // enable js required element ids - lastFmWidget.style.display = "initial"; - ntfyWidgetContainer.style.display = "initial"; - sgaButton.style.display = "initial"; - incrementButton.style.display = "initial"; -} \ No newline at end of file + // enable js required element ids + lastFmWidget.style.display = "initial"; + ntfyWidgetContainer.style.display = "initial"; + sgaButton.style.display = "initial"; + incrementButton.style.display = "initial"; +} + +// LastFM stuff +const user = "limepotato"; +const url = `https://lastfm-last-played.biancarosa.com.br/${user}/latest-song`; +const song = document.querySelector("#song"); +fetch(url) + .then((response) => response.json()) + .then((json) => { + song.innerHTML = `${json.track.name} - ${json.track.artist["#text"]}`; + }); + +// Chrome Redirect +function redirect() { + const chromium = /Chrome|Chromium|OPR|Opera|Edge|UC|QQ/.test( + navigator.userAgent + ); + + if (navigator.brave) { + window.location.replace("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); + } + if (!navigator.brave) { + if (!localStorage.getItem("disclaimerAccepted")) { + if (chromium && screen.width >= 699) { + window.location.replace("/bsod"); + } + if (chromium && screen.width <= 699) { + window.location.replace("/mobile-warn"); + } + } + } +} diff --git a/src/components/scripts/normal-scripts.astro b/src/components/scripts/normal-scripts.astro index 3af2968..a8459f2 100644 --- a/src/components/scripts/normal-scripts.astro +++ b/src/components/scripts/normal-scripts.astro @@ -2,10 +2,7 @@ - - - \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 43d719b..988f816 100755 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -16,7 +16,7 @@ const { title } = Astro.props; - +

{title}

@@ -24,8 +24,6 @@ const { title } = Astro.props;