patch error on no links

This commit is contained in:
Holly Stubbs 2024-10-02 22:25:08 +01:00
parent 25c459e71c
commit f72bdd3f27
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name MultiProbe
// @namespace https://*.angusnicneven.com/*
// @version 20241002.3
// @version 20241002.4
// @description Probe with friends!
// @author tgpholly
// @match https://*.angusnicneven.com/*
@ -35,6 +35,7 @@ if (!window.TE_ACTIVE) {
const windowLocation = window.location.href;
window.multiprobe_debug = false;
window.multiprobe_connectLocal = false;
const SITE_DEFAULT_CURSOR = {
"localhost": "https://angusnicneven.com/cursor/rrw.png",
@ -54,7 +55,7 @@ console.log("[MP] MultiProbe init");
'use strict';
// Make sure to change the userscript version too!!!!!!!!!!
const USERSCRIPT_VERSION_RAW = "20241002.3";
const USERSCRIPT_VERSION_RAW = "20241002.4";
const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", ""));
if (!continueRunningScript) {
@ -93,6 +94,13 @@ console.log("[MP] MultiProbe init");
if (!hoverChangeElement) {
hoverChangeElement = document.querySelector(".probedata");
}
if (!hoverChangeElement) {
hoverChangeElement = document.createElement("a");
hoverChangeElement.innerText = "css test element";
hoverChangeElement.id = "MULTIPROBE_CSS_TEST_ELEMENT";
hoverChangeElement.style = "display:none";
document.body.appendChild(hoverChangeElement);
}
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")) {
@ -460,6 +468,9 @@ mp_button {
popupRoot.style = "position:fixed;left:50%;top:0;z-index:9999998";
document.documentElement.appendChild(popupRoot);
const popupSound = new Audio("https://eusv.net/kdHl7VYI1XMS4c");
document.documentElement.appendChild(popupSound);
function createGroupUser(username, location) {
const user = document.createElement("mp_group_user");
user.classList.add("groupui-user");
@ -497,6 +508,21 @@ mp_button {
}
}, 1000);
const debugMessageContainer = document.createElement("mp_container");
debugMessageContainer.style = "position:fixed;top:0;left:0;padding:4px;pointer-events:none;text-shadow: 0px 0px 4px black";
document.documentElement.appendChild(debugMessageContainer);
if (window.multiprobe_debug) {
const debugText = document.createElement("mp_text");
debugText.innerText = "RUNNING IN DEBUG";
debugMessageContainer.appendChild(debugText);
}
if (window.multiprobe_connectLocal) {
const debugConnectLocal = document.createElement("mp_text");
debugConnectLocal.innerText = "CONNECTED TO DEV SERVER";
debugMessageContainer.appendChild(debugConnectLocal);
}
let needsToUpdate = false;
console.log("[MP] Checking for new versions...");
const versionFetchAddress = windowLocation.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/version" : "https://multiprobe.eusv.net/api/version";
@ -734,7 +760,7 @@ mp_button {
const Buffer = getBufferClass();
console.log("[MP] Connecting to realtime server...");
ws = new WebSocket(windowLocation.includes("//localhost:") ? "ws://localhost:38195" : "wss://ws.eusv.net/t00mp");
ws = new WebSocket((windowLocation.includes("//localhost:") || window.multiprobe_connectLocal) ? "wss://ws.eusv.net/t00mpdev" : "wss://ws.eusv.net/t00mp");
let keepAliveInterval;
ws.onopen = () => {
console.log("[MP] Connected! Authenticating...");
@ -1038,7 +1064,16 @@ mp_button {
document.documentElement.appendChild(bg);
}
const badgeQueue = [];
let displaying = false;
function createBadgePopup(title, description, image) {
if (displaying) {
badgeQueue.push([title, description, image]);
return;
}
displaying = true;
const popup = document.createElement("mp_badge");
popup.classList.add("badgepop");
popup.classList.add("badgepopcreate");
@ -1050,6 +1085,7 @@ mp_button {
badgeImage.onload = () => {
popup.classList.remove("badgepopcreate");
popup.classList.add("badgepopin");
setTimeout(() => popupSound.play(), 100);
};
popup.appendChild(badgeImage);
@ -1071,8 +1107,14 @@ mp_button {
setTimeout(() => {
popup.remove();
}, 500);
displaying = false;
if (badgeQueue.length > 0) {
const badgeData = badgeQueue.splice(0, 1)[0];
setTimeout(() => createBadgePopup(badgeData[0], badgeData[1], badgeData[2]), 0);
}
}, 5350);
}
window.createBadgePopup = createBadgePopup;
function createLoginDialog() {
const bg = document.createElement("mp_container");
@ -1129,7 +1171,7 @@ mp_button {
doNotButton.disabled = true;
title.innerText = "Authenticating...";
fetch(windowLocation.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/login" : "https://multiprobe.eusv.net/api/login", {
fetch((windowLocation.replace("127.0.0.1", "localhost").includes("//localhost:") || window.multiprobe_connectLocal) ? "http://localhost:38194/api/login" : "https://multiprobe.eusv.net/api/login", {
method: "POST",
body: `username=${encodeURIComponent(username.value)}&password=${encodeURIComponent(password.value)}`,
headers: {