diff --git a/client/Terminal-00-Multiuser.user.js b/client/Terminal-00-Multiuser.user.js index a81cbd7..3e4b81e 100644 --- a/client/Terminal-00-Multiuser.user.js +++ b/client/Terminal-00-Multiuser.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name MultiProbe // @namespace https://*.angusnicneven.com/* -// @version 20241008.3 +// @version 20241009.0 // @description Probe with friends! // @author tgpholly // @match https://*.angusnicneven.com/* @@ -55,7 +55,7 @@ console.log("[MP] MultiProbe init"); 'use strict'; // Make sure to change the userscript version too!!!!!!!!!! - const USERSCRIPT_VERSION_RAW = "20241008.3"; + const USERSCRIPT_VERSION_RAW = "20241009.0"; const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", "")); if (!continueRunningScript) { @@ -434,13 +434,7 @@ mp_button { localStorage["mpconnectonload"] = true; } - let marginComputedStyle = window.getComputedStyle(document.body); - const bodyMarginTop = parseInt(marginComputedStyle.marginTop.replace("px", "")); - const bodyMarginLeft = parseInt(marginComputedStyle.marginLeft.replace("px", "")); - const bodyMarginRight = parseInt(marginComputedStyle.marginRight.replace("px", "")); - const otherCursors = document.createElement("mp_cursors"); - otherCursors.style.top = `-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMarginTop)}px`; otherCursors.id = "otherCursors"; document.documentElement.appendChild(otherCursors); @@ -497,15 +491,15 @@ mp_button { groupUsers.appendChild(user); } - let clientWidth = document.body.getBoundingClientRect().width; - let bodyBoundingRect = document.body.getBoundingClientRect(); + let clientWidth = document.documentElement.getBoundingClientRect().width; + let bodyBoundingRect = document.documentElement.getBoundingClientRect(); setInterval(() => { - bodyBoundingRect = document.body.getBoundingClientRect(); - if (document.body.scrollHeight > window.innerHeight) { - otherCursors.style = `width:${clientWidth = (bodyBoundingRect.width + bodyMarginRight + bodyMarginLeft)}px;height:${document.body.scrollHeight}px;top:-${((window.scrollY + bodyBoundingRect.top) - bodyMarginTop)}px;cursor: ${cssCursor};`; + bodyBoundingRect = document.documentElement.getBoundingClientRect(); + if (document.documentElement.scrollHeight > window.innerHeight) { + otherCursors.style = `width:${clientWidth = bodyBoundingRect.width}px;height:${document.documentElement.scrollHeight}px;cursor: ${cssCursor};`; } else { - otherCursors.style = `width:${clientWidth = (bodyBoundingRect.width + bodyMarginRight + bodyMarginLeft)}px;height:${window.innerHeight}px;top:-${((window.scrollY + bodyBoundingRect.top) - bodyMarginTop)}px;cursor: ${cssCursor};`; + otherCursors.style = `width:${clientWidth = bodyBoundingRect.width}px;height:${window.innerHeight}px;cursor: ${cssCursor};`; } }, 1000); @@ -678,7 +672,7 @@ mp_button { window.onmousemove = (e) => { currentMouseX = (rawMouseX = e.clientX) + window.scrollX; - currentMouseY = (rawMouseY = e.clientY) + window.scrollY + ((window.scrollY + bodyBoundingRect.top) - bodyMarginTop); + currentMouseY = (rawMouseY = e.clientY) + window.scrollY; if (selfCursor) { selfCursor.rawSetPosInit(currentMouseX / clientWidth, currentMouseY); selfCursor.updateCursor(); @@ -686,9 +680,9 @@ mp_button { } window.onscroll = () => { - bodyBoundingRect = document.body.getBoundingClientRect(); + bodyBoundingRect = document.documentElement.getBoundingClientRect(); currentMouseX = rawMouseX + window.scrollX; - currentMouseY = rawMouseY + window.scrollY + ((window.scrollY + bodyBoundingRect.top) - bodyMarginTop); + currentMouseY = rawMouseY + window.scrollY; if (selfCursor) { selfCursor.rawSetPosInit(currentMouseX / clientWidth, currentMouseY); selfCursor.updateCursor(); @@ -706,7 +700,7 @@ mp_button { if (ws && ready) { if (allowedPings > 0) { allowedPings--; - ws.send(createWriter(Endian.LE, 9).writeUByte(MessageType.Ping).writeFloat((rawMouseX + window.scrollX - 32) / clientWidth).writeInt(rawMouseY + window.scrollY - 32 + ((window.scrollY + bodyBoundingRect.top) - bodyMarginTop)).toBuffer()); + ws.send(createWriter(Endian.LE, 9).writeUByte(MessageType.Ping).writeFloat((rawMouseX + window.scrollX - 32) / clientWidth).writeInt(rawMouseY + window.scrollY - 32).toBuffer()); } } } else if (e.key === "n") {