allow hiding the self cursor

This commit is contained in:
Holly Stubbs 2024-04-20 17:34:32 +01:00
parent 7864a2b252
commit c895312f7a
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name Terminal 00 Multiuser
// @namespace https://*.angusnicneven.com/*
// @version 20240420.1
// @version 20240420.2
// @description Probe with friends!
// @author tgpholly
// @match https://*.angusnicneven.com/*
@ -153,6 +153,7 @@ if (!window.TE_ACTIVE) {
rawSetPos(x, y) {
if (!this.hasBeenMoved) {
this.element.visibility = "";
this.hasBeenMoved = true;
}
this.targetX = Math.round(x * clientWidth);
@ -162,6 +163,7 @@ if (!window.TE_ACTIVE) {
rawSetPosInit(x, y) {
if (!this.hasBeenMoved) {
this.element.visibility = "";
this.hasBeenMoved = true;
}
this.actualX = this.targetX = Math.round(x * clientWidth);
@ -231,6 +233,10 @@ if (!window.TE_ACTIVE) {
ws.send(createWriter(Endian.LE, 9).writeByte(MessageType.Ping).writeFloat((rawMouseX + document.body.scrollLeft - 32) / clientWidth).writeInt(rawMouseY + document.body.scrollTop - 32).toBuffer());
}
}
} else if (e.key === "n") {
if (ws && ready && selfCursor) {
localStorage["t00mp_cursorStyle"] = selfCursor.element.style.visibility = selfCursor.element.style.visibility === "hidden" ? "" : "hidden";
}
}
}
@ -279,6 +285,8 @@ if (!window.TE_ACTIVE) {
ws.onopen = () => {
selfCursor = new RemoteClient(username);
selfCursor.probeImage.style.visibility = "hidden";
selfCursor.element.style.visibility = localStorage["t00mp_cursorStyle"] ?? "hidden";
selfCursor.hasBeenMoved = true;
const currentPage = window.location.href.split("/").slice(3).join("/");
ws.send(createWriter(Endian.LE, 4 + username.length + currentPage.length).writeByte(MessageType.ClientDetails).writeShortString(username).writeString(currentPage).toBuffer());
keepAliveInterval = setInterval(() => {