improve support for heavenonline

This commit is contained in:
Holly Stubbs 2024-10-02 21:18:03 +01:00
parent 014ce4743c
commit 25c459e71c
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E

View file

@ -77,8 +77,15 @@ console.log("[MP] MultiProbe init");
BadgeUnlock: 9 BadgeUnlock: 9
}; };
let cssCursor = "";
let cssHoverCursor = "";
let pageLoadCompleted = true;
console.log("[MP] Injecting custom styles...");
const styles = document.createElement("style");
function updateStyles() {
let cursorImageI = window.getComputedStyle(document.body).cursor; 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}`; 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")) { if (cssCursor.includes("undefined")) {
cssCursor = "auto"; cssCursor = "auto";
} }
@ -87,15 +94,14 @@ console.log("[MP] MultiProbe init");
hoverChangeElement = document.querySelector(".probedata"); hoverChangeElement = document.querySelector(".probedata");
} }
let cursorHoverImageI = window.getComputedStyle(hoverChangeElement).cursor; 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}`; 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")) { if (cssHoverCursor.includes("undefined")) {
cssHoverCursor = "auto"; cssHoverCursor = "auto";
} }
console.log("[MP] Injecting custom styles...");
const styles = document.createElement("style");
styles.innerHTML = ` styles.innerHTML = `
html { html {
cursor: ${cssCursor}; ${pageLoadCompleted ? `cursor: ${cssCursor};` : ""}
} }
#otherCursors { #otherCursors {
@ -391,6 +397,27 @@ mp_button {
opacity: 1; opacity: 1;
} }
`.split("\n").join("").split("\r").join("").split("\t").join(""); `.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); document.head.appendChild(styles);