From 25c459e71c5bdbc55447fe0e08b6dd22f00d352c Mon Sep 17 00:00:00 2001 From: Holly Date: Wed, 2 Oct 2024 21:18:03 +0100 Subject: [PATCH] improve support for heavenonline --- client/Terminal-00-Multiuser.user.js | 59 ++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/client/Terminal-00-Multiuser.user.js b/client/Terminal-00-Multiuser.user.js index b42f742..1f0c666 100644 --- a/client/Terminal-00-Multiuser.user.js +++ b/client/Terminal-00-Multiuser.user.js @@ -77,25 +77,31 @@ console.log("[MP] MultiProbe init"); BadgeUnlock: 9 }; - let cursorImageI = window.getComputedStyle(document.body).cursor; - let cssCursor = `${cursorImageI === "auto" || !cursorImageI.includes("url") ? `url(${SITE_DEFAULT_CURSOR[window.location.href.split("//")[1].split("/")[0].split(":")[0]]}) 11 11, auto` : cursorImageI}`; - if (cssCursor.includes("undefined")) { - cssCursor = "auto"; - } - let hoverChangeElement = document.querySelector("a"); - if (!hoverChangeElement) { - hoverChangeElement = document.querySelector(".probedata"); - } - let cursorHoverImageI = window.getComputedStyle(hoverChangeElement).cursor; - let cssHoverCursor = `${cursorHoverImageI === "auto" || !cursorHoverImageI.includes("url") ? `url(${SITE_DEFAULT_HOVER_CURSOR[window.location.href.split("//")[1].split("/")[0].split(":")[0]]}) 11 11, auto` : cursorHoverImageI}`; - if (cssHoverCursor.includes("undefined")) { - cssHoverCursor = "auto"; - } + let cssCursor = ""; + let cssHoverCursor = ""; + let pageLoadCompleted = true; + console.log("[MP] Injecting custom styles..."); const styles = document.createElement("style"); - styles.innerHTML = ` + function updateStyles() { + let cursorImageI = window.getComputedStyle(document.body).cursor; + cssCursor = `${cursorImageI === "auto" || !cursorImageI.includes("url") ? `url(${SITE_DEFAULT_CURSOR[window.location.href.split("//")[1].split("/")[0].split(":")[0]]}) 11 11, auto` : cursorImageI}`; + if (cssCursor.includes("undefined")) { + cssCursor = "auto"; + } + let hoverChangeElement = document.querySelector("a"); + if (!hoverChangeElement) { + hoverChangeElement = document.querySelector(".probedata"); + } + let cursorHoverImageI = window.getComputedStyle(hoverChangeElement).cursor; + cssHoverCursor = `${cursorHoverImageI === "auto" || !cursorHoverImageI.includes("url") ? `url(${SITE_DEFAULT_HOVER_CURSOR[window.location.href.split("//")[1].split("/")[0].split(":")[0]]}) 11 11, auto` : cursorHoverImageI}`; + if (cssHoverCursor.includes("undefined")) { + cssHoverCursor = "auto"; + } + + styles.innerHTML = ` html { - cursor: ${cssCursor}; + ${pageLoadCompleted ? `cursor: ${cssCursor};` : ""} } #otherCursors { @@ -391,6 +397,27 @@ mp_button { opacity: 1; } `.split("\n").join("").split("\r").join("").split("\t").join(""); + } + + // Cursed way of detecting heavenonline load + if (window.location.href.split("://")[1].split("/")[0] === "heavenonline.xyz") { + pageLoadCompleted = false; + const oldConsoleLog = console.log; + console.log = function(...args) { + if (args.length >= 1) { + if (args[0].trim() === `Page is ready at ${finished}.`) { + console.log = oldConsoleLog; + console.log("[MP] Reverted console.log override."); + pageLoadCompleted = true; + updateStyles(); + } + } + + oldConsoleLog(...args); + } + } else { + updateStyles(); + } document.head.appendChild(styles);