fixes for 001b hub

This commit is contained in:
Holly Stubbs 2024-05-02 16:33:50 +01:00
parent 418f52ab45
commit 51df305f5a
Signed by: tgpholly
GPG Key ID: B8583C4B7D18119E
1 changed files with 11 additions and 10 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name MultiProbe // @name MultiProbe
// @namespace https://*.angusnicneven.com/* // @namespace https://*.angusnicneven.com/*
// @version 20240502.1 // @version 20240502.2
// @description Probe with friends! // @description Probe with friends!
// @author tgpholly // @author tgpholly
// @match https://*.angusnicneven.com/* // @match https://*.angusnicneven.com/*
@ -36,7 +36,7 @@ if (!window.TE_ACTIVE) {
'use strict'; 'use strict';
// Make sure to change the userscript version too!!!!!!!!!! // Make sure to change the userscript version too!!!!!!!!!!
const USERSCRIPT_VERSION_RAW = "20240502.1"; const USERSCRIPT_VERSION_RAW = "20240502.2";
const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", "")); const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", ""));
if (!continueRunningScript) { if (!continueRunningScript) {
@ -204,8 +204,9 @@ kbd {
if (!localStorage["mpconnectonload"]) { if (!localStorage["mpconnectonload"]) {
localStorage["mpconnectonload"] = true; localStorage["mpconnectonload"] = true;
} }
const otherCursors = document.createElement("div"); const otherCursors = document.createElement("div");
otherCursors.style.top = `-${window.scrollY + document.body.getBoundingClientRect().top}px`;
otherCursors.id = "otherCursors"; otherCursors.id = "otherCursors";
document.body.appendChild(otherCursors); document.body.appendChild(otherCursors);
@ -256,9 +257,9 @@ kbd {
setInterval(() => { setInterval(() => {
if (document.body.scrollHeight > window.innerHeight) { if (document.body.scrollHeight > window.innerHeight) {
otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${document.body.scrollHeight}px`; otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${document.body.scrollHeight}px;top:-${window.scrollY + document.body.getBoundingClientRect().top}px`;
} else { } else {
otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${window.innerHeight}px`; otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${window.innerHeight}px;top:-${window.scrollY + document.body.getBoundingClientRect().top}px`;
} }
}, 1000); }, 1000);
@ -374,8 +375,8 @@ kbd {
let rawMouseY = 0; let rawMouseY = 0;
window.onmousemove = (e) => { window.onmousemove = (e) => {
currentMouseX = (rawMouseX = e.clientX) + document.body.scrollLeft; currentMouseX = (rawMouseX = e.clientX) + window.scrollX;
currentMouseY = (rawMouseY = e.clientY) + document.body.scrollTop; currentMouseY = (rawMouseY = e.clientY) + window.scrollY;
if (selfCursor) { if (selfCursor) {
selfCursor.rawSetPosInit(currentMouseX / clientWidth, currentMouseY); selfCursor.rawSetPosInit(currentMouseX / clientWidth, currentMouseY);
selfCursor.updateCursor(); selfCursor.updateCursor();
@ -383,8 +384,8 @@ kbd {
} }
window.onscroll = () => { window.onscroll = () => {
currentMouseX = rawMouseX + document.body.scrollLeft; currentMouseX = rawMouseX + window.scrollX;
currentMouseY = rawMouseY + document.body.scrollTop; currentMouseY = rawMouseY + window.scrollY;
if (selfCursor) { if (selfCursor) {
selfCursor.rawSetPosInit(currentMouseX / clientWidth, currentMouseY); selfCursor.rawSetPosInit(currentMouseX / clientWidth, currentMouseY);
selfCursor.updateCursor(); selfCursor.updateCursor();
@ -397,7 +398,7 @@ kbd {
if (ws && ready) { if (ws && ready) {
if (allowedPings > 0) { if (allowedPings > 0) {
allowedPings--; allowedPings--;
ws.send(createWriter(Endian.LE, 9).writeByte(MessageType.Ping).writeFloat((rawMouseX + document.body.scrollLeft - 32) / clientWidth).writeInt(rawMouseY + document.body.scrollTop - 32).toBuffer()); ws.send(createWriter(Endian.LE, 9).writeByte(MessageType.Ping).writeFloat((rawMouseX + window.scrollX - 32) / clientWidth).writeInt(rawMouseY + window.scrollY - 32).toBuffer());
} }
} }
} else if (e.key === "n") { } else if (e.key === "n") {