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== // ==UserScript==
// @name Terminal 00 Multiuser // @name Terminal 00 Multiuser
// @namespace https://*.angusnicneven.com/* // @namespace https://*.angusnicneven.com/*
// @version 20240420.1 // @version 20240420.2
// @description Probe with friends! // @description Probe with friends!
// @author tgpholly // @author tgpholly
// @match https://*.angusnicneven.com/* // @match https://*.angusnicneven.com/*
@ -153,6 +153,7 @@ if (!window.TE_ACTIVE) {
rawSetPos(x, y) { rawSetPos(x, y) {
if (!this.hasBeenMoved) { if (!this.hasBeenMoved) {
this.element.visibility = ""; this.element.visibility = "";
this.hasBeenMoved = true;
} }
this.targetX = Math.round(x * clientWidth); this.targetX = Math.round(x * clientWidth);
@ -162,6 +163,7 @@ if (!window.TE_ACTIVE) {
rawSetPosInit(x, y) { rawSetPosInit(x, y) {
if (!this.hasBeenMoved) { if (!this.hasBeenMoved) {
this.element.visibility = ""; this.element.visibility = "";
this.hasBeenMoved = true;
} }
this.actualX = this.targetX = Math.round(x * clientWidth); 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()); 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 = () => { ws.onopen = () => {
selfCursor = new RemoteClient(username); selfCursor = new RemoteClient(username);
selfCursor.probeImage.style.visibility = "hidden"; 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("/"); 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()); ws.send(createWriter(Endian.LE, 4 + username.length + currentPage.length).writeByte(MessageType.ClientDetails).writeShortString(username).writeString(currentPage).toBuffer());
keepAliveInterval = setInterval(() => { keepAliveInterval = setInterval(() => {