This commit is contained in:
Holly Stubbs 2024-05-07 22:17:30 +01:00
parent bc7fb72800
commit e3fb938117
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E

View file

@ -35,6 +35,8 @@ if (!window.TE_ACTIVE) {
const windowLocation = window.location.href;
window.multiprobe_debug = false;
console.log("[MP] MultiProbe init");
(function() {
'use strict';
@ -61,6 +63,7 @@ window.multiprobe_debug = false;
};
let cursorImageI = window.getComputedStyle(document.body).cursor;
console.log("[MP] Injecting custom styles...");
const styles = document.createElement("style");
styles.innerHTML = `
html {
@ -288,15 +291,18 @@ kbd {
}, 1000);
let needsToUpdate = false;
console.log("[MP] Checking for new versions...");
const versionFetchAddress = windowLocation.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/version" : "https://multiprobe.eusv.net/api/version";
fetch(versionFetchAddress, { method: "post" }).then(response => {
console.log("hi");
response.text().then(versionNumberRaw => {
const versionNumber = parseInt(versionNumberRaw);
if (versionNumber > USERSCRIPT_VERSION) {
// We're out of date >:(
needsToUpdate = true;
createUpdateDialog(`${versionNumberRaw.slice(0, versionNumberRaw.length - 1)}.${versionNumberRaw.slice(-1)}`);
console.log("[MP] We're out of date :(");
} else {
console.log("[MP] We're up to date!");
}
});
});
@ -439,7 +445,6 @@ kbd {
groupPopper.click();
}
}
console.log(e.key);
}
window.onkeydown = (e) => {
@ -491,9 +496,11 @@ kbd {
function doConnect(apiKey) {
const Buffer = getBufferClass();
console.log("[MP] Connecting to realtime server...");
ws = new WebSocket(windowLocation.includes("//localhost:") ? "ws://localhost:38195" : "wss://ws.eusv.net/t00mp");
let keepAliveInterval;
ws.onopen = () => {
console.log("[MP] Connected! Authenticating...");
otherCursors.innerHTML = "";
selfCursor = new RemoteClient(localStorage["t00mp_username"]);
selfCursor.probeImage.style.visibility = "hidden";
@ -534,6 +541,7 @@ kbd {
if (!needsToUpdate) {
createFirstTimeDialog();
}
console.log("[MP] Authenticated!");
break;
}
case MessageType.ClientJoined:
@ -865,4 +873,6 @@ kbd {
if (localStorage["mpapikey"] && localStorage["mpapikey"] !== "" && localStorage["mpconnectonload"] === "true") {
doConnect(localStorage["mpapikey"]);
}
console.log("[MP] Init complete.");
})();