fix margins offsetting container + html cursor css override

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

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name MultiProbe // @name MultiProbe
// @namespace https://*.angusnicneven.com/* // @namespace https://*.angusnicneven.com/*
// @version 20240502.2 // @version 20240502.3
// @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.2"; const USERSCRIPT_VERSION_RAW = "20240502.3";
const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", "")); const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", ""));
if (!continueRunningScript) { if (!continueRunningScript) {
@ -57,8 +57,13 @@ if (!window.TE_ACTIVE) {
GroupData: 7 GroupData: 7
}; };
let cursorImageI = window.getComputedStyle(document.body).cursor;
const styles = document.createElement("style"); const styles = document.createElement("style");
styles.innerHTML = ` styles.innerHTML = `
html {
cursor: ${cursorImageI};
}
#otherCursors { #otherCursors {
position: absolute; position: absolute;
top:0px; top:0px;
@ -199,14 +204,17 @@ kbd {
} }
`.split("\n").join("").split("\r").join("").split("\t").join(""); `.split("\n").join("").split("\r").join("").split("\t").join("");
document.head.appendChild(styles); document.head.appendChild(styles);
if (!localStorage["mpconnectonload"]) { if (!localStorage["mpconnectonload"]) {
localStorage["mpconnectonload"] = true; localStorage["mpconnectonload"] = true;
} }
const bodyMargin = parseInt(window.getComputedStyle(document.body).marginTop.replace("px", ""));
const otherCursors = document.createElement("div"); const otherCursors = document.createElement("div");
otherCursors.style.top = `-${window.scrollY + document.body.getBoundingClientRect().top}px`; otherCursors.style.top = `-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMargin)}px`;
otherCursors.id = "otherCursors"; otherCursors.id = "otherCursors";
document.body.appendChild(otherCursors); document.body.appendChild(otherCursors);
@ -257,9 +265,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;top:-${window.scrollY + document.body.getBoundingClientRect().top}px`; otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${document.body.scrollHeight}px;top:-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMargin)}px`;
} else { } else {
otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${window.innerHeight}px;top:-${window.scrollY + document.body.getBoundingClientRect().top}px`; otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${window.innerHeight}px;top:-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMargin)}px`;
} }
}, 1000); }, 1000);