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

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name MultiProbe
// @namespace https://*.angusnicneven.com/*
// @version 20240502.2
// @version 20240502.3
// @description Probe with friends!
// @author tgpholly
// @match https://*.angusnicneven.com/*
@ -36,7 +36,7 @@ if (!window.TE_ACTIVE) {
'use strict';
// 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(".", ""));
if (!continueRunningScript) {
@ -57,8 +57,13 @@ if (!window.TE_ACTIVE) {
GroupData: 7
};
let cursorImageI = window.getComputedStyle(document.body).cursor;
const styles = document.createElement("style");
styles.innerHTML = `
html {
cursor: ${cursorImageI};
}
#otherCursors {
position: absolute;
top:0px;
@ -199,14 +204,17 @@ kbd {
}
`.split("\n").join("").split("\r").join("").split("\t").join("");
document.head.appendChild(styles);
if (!localStorage["mpconnectonload"]) {
localStorage["mpconnectonload"] = true;
}
const bodyMargin = parseInt(window.getComputedStyle(document.body).marginTop.replace("px", ""));
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";
document.body.appendChild(otherCursors);
@ -257,9 +265,9 @@ kbd {
setInterval(() => {
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 {
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);