Compare commits
No commits in common. "e3fb9381179850ab4a9a9e27ea24674b502a48bd" and "cd170dc471262c9eacb2d3e13272950b4cd2ff89" have entirely different histories.
e3fb938117
...
cd170dc471
1 changed files with 14 additions and 50 deletions
|
@ -32,11 +32,8 @@ if (!window.TE_ACTIVE) {
|
|||
setInterval(nukeCC, 1000);
|
||||
}
|
||||
|
||||
const windowLocation = window.location.href;
|
||||
window.multiprobe_debug = false;
|
||||
|
||||
console.log("[MP] MultiProbe init");
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
|
@ -63,7 +60,6 @@ console.log("[MP] MultiProbe init");
|
|||
};
|
||||
|
||||
let cursorImageI = window.getComputedStyle(document.body).cursor;
|
||||
console.log("[MP] Injecting custom styles...");
|
||||
const styles = document.createElement("style");
|
||||
styles.innerHTML = `
|
||||
html {
|
||||
|
@ -79,8 +75,6 @@ html {
|
|||
z-index: 999999999;
|
||||
pointer-events: none;
|
||||
overflow:hidden;
|
||||
text-shadow: none!important;
|
||||
font-family: Arial,sans-serif;
|
||||
}
|
||||
|
||||
#otherCursors img {
|
||||
|
@ -124,9 +118,6 @@ html {
|
|||
background-color: black;
|
||||
color: white;
|
||||
z-index:9999998;
|
||||
text-shadow: none!important;
|
||||
font-family: Arial,sans-serif;
|
||||
font-size: unset !important;
|
||||
}
|
||||
|
||||
.groupui-popper {
|
||||
|
@ -150,7 +141,6 @@ html {
|
|||
height: 2rem;
|
||||
line-height: 2rem;
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
.groupui-scrollbox {
|
||||
|
@ -160,8 +150,6 @@ html {
|
|||
width: 100%;
|
||||
height: calc(100% - 2rem);
|
||||
overflow-y: scroll;
|
||||
font-family: Arial,sans-serif;
|
||||
font-size: unset !important;
|
||||
}
|
||||
|
||||
.groupui-user {
|
||||
|
@ -207,8 +195,6 @@ kbd {
|
|||
line-height: 1;
|
||||
padding: 2px 4px;
|
||||
white-space: nowrap;
|
||||
font-family: Arial,sans-serif;
|
||||
font-size: unset !important;
|
||||
}
|
||||
|
||||
.mplink, .mplink:visited {
|
||||
|
@ -227,13 +213,10 @@ kbd {
|
|||
localStorage["mpconnectonload"] = true;
|
||||
}
|
||||
|
||||
let marginComputedStyle = window.getComputedStyle(document.body);
|
||||
const bodyMarginTop = parseInt(marginComputedStyle.marginTop.replace("px", ""));
|
||||
const bodyMarginLeft = parseInt(marginComputedStyle.marginLeft.replace("px", ""));
|
||||
const bodyMarginRight = parseInt(marginComputedStyle.marginRight.replace("px", ""));
|
||||
const bodyMargin = parseInt(window.getComputedStyle(document.body).marginTop.replace("px", ""));
|
||||
|
||||
const otherCursors = document.createElement("div");
|
||||
otherCursors.style.top = `-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMarginTop)}px`;
|
||||
otherCursors.style.top = `-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMargin)}px`;
|
||||
otherCursors.id = "otherCursors";
|
||||
document.body.appendChild(otherCursors);
|
||||
|
||||
|
@ -284,25 +267,22 @@ kbd {
|
|||
|
||||
setInterval(() => {
|
||||
if (document.body.scrollHeight > window.innerHeight) {
|
||||
otherCursors.style = `width:${clientWidth = (document.body.getBoundingClientRect().width + bodyMarginRight + bodyMarginLeft)}px;height:${document.body.scrollHeight}px;top:-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMarginTop)}px;cursor: ${cursorImageI};`;
|
||||
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 + bodyMarginRight + bodyMarginLeft)}px;height:${window.innerHeight}px;top:-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMarginTop)}px;cursor: ${cursorImageI};`;
|
||||
otherCursors.style = `width:${clientWidth = document.body.getBoundingClientRect().width}px;height:${window.innerHeight}px;top:-${((window.scrollY + document.body.getBoundingClientRect().top) - bodyMargin)}px`;
|
||||
}
|
||||
}, 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";
|
||||
const versionFetchAddress = window.location.href.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!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -447,13 +427,6 @@ kbd {
|
|||
}
|
||||
}
|
||||
|
||||
window.onkeydown = (e) => {
|
||||
if (!windowContainer && e.key === "F1") {
|
||||
localStorage["mpshowfirsttime"] = "true";
|
||||
createFirstTimeDialog();
|
||||
}
|
||||
};
|
||||
|
||||
function lerp(value1, value2, amount) {
|
||||
return value1 + (value2 - value1) * amount;
|
||||
}
|
||||
|
@ -496,17 +469,15 @@ 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");
|
||||
ws = new WebSocket(window.location.href.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";
|
||||
selfCursor.element.style.visibility = localStorage["t00mp_cursorStyle"] ?? "hidden";
|
||||
selfCursor.hasBeenMoved = true;
|
||||
const currentPage = windowLocation.split("/").slice(3).join("/");
|
||||
const currentPage = window.location.href.split("/").slice(3).join("/");
|
||||
ws.send(createWriter(Endian.LE, 4 + apiKey.length + currentPage.length)
|
||||
.writeByte(MessageType.ClientDetails)
|
||||
.writeShortString(apiKey)
|
||||
|
@ -541,7 +512,6 @@ kbd {
|
|||
if (!needsToUpdate) {
|
||||
createFirstTimeDialog();
|
||||
}
|
||||
console.log("[MP] Authenticated!");
|
||||
break;
|
||||
}
|
||||
case MessageType.ClientJoined:
|
||||
|
@ -628,7 +598,7 @@ kbd {
|
|||
function createOnlineDialog() {
|
||||
const bg = document.createElement("div");
|
||||
windowContainer = bg;
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5);text-shadow: none!important;font-family: Arial,sans-serif;font-size: unset !important;";
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5)";
|
||||
const dialog = document.createElement("div");
|
||||
dialog.style = "position:absolute;top:50%;left:50%;min-width:15rem;background-color:#343434;padding:1rem;transform:translate(-50%,-50%);text-align:center;color:white";
|
||||
bg.appendChild(dialog);
|
||||
|
@ -689,7 +659,7 @@ kbd {
|
|||
|
||||
function createUpdateDialog(versionNumber) {
|
||||
const bg = document.createElement("div");
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5);text-shadow: none!important;font-family: Arial,sans-serif;font-size: unset !important;";
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5)";
|
||||
const dialog = document.createElement("div");
|
||||
dialog.style = "position:absolute;top:50%;left:50%;min-width:15rem;background-color:#343434;padding:1rem;transform:translate(-50%,-50%);text-align:center;color:white";
|
||||
bg.appendChild(dialog);
|
||||
|
@ -724,7 +694,7 @@ kbd {
|
|||
|
||||
const bg = document.createElement("div");
|
||||
windowContainer = bg;
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5);text-shadow: none!important;font-family: Arial,sans-serif;font-size: unset !important;";
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5)";
|
||||
const dialog = document.createElement("div");
|
||||
dialog.style = "position:absolute;top:50%;left:50%;min-width:15rem;background-color:#343434;padding:1rem;transform:translate(-50%,-50%);text-align:center;color:white";
|
||||
bg.appendChild(dialog);
|
||||
|
@ -749,10 +719,6 @@ kbd {
|
|||
groupLI.innerHTML = "You can show/hide the party sidebar if you are in one by pressing <kbd>G</kbd>";
|
||||
actionList.appendChild(groupLI);
|
||||
|
||||
const helpTip = document.createElement("li");
|
||||
helpTip.innerHTML = "If you press <kbd>F1</kbd> you can open this help again.";
|
||||
actionList.appendChild(helpTip);
|
||||
|
||||
const buttons = document.createElement("div");
|
||||
buttons.style.marginTop = "1rem";
|
||||
|
||||
|
@ -773,7 +739,7 @@ kbd {
|
|||
function createLoginDialog() {
|
||||
const bg = document.createElement("div");
|
||||
windowContainer = bg;
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5);text-shadow: none!important;font-family: Arial,sans-serif;font-size: unset !important;";
|
||||
bg.style = "z-index:1000000000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.5)";
|
||||
const dialog = document.createElement("div");
|
||||
dialog.style = "position:absolute;top:50%;left:50%;width:15rem;background-color:#343434;padding-bottom:1rem;transform:translate(-50%,-50%);text-align:center;color:white";
|
||||
bg.appendChild(dialog);
|
||||
|
@ -825,7 +791,7 @@ kbd {
|
|||
doNotButton.disabled = true;
|
||||
|
||||
title.innerText = "Authenticating...";
|
||||
fetch(windowLocation.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/login" : "https://multiprobe.eusv.net/api/login", {
|
||||
fetch(window.location.href.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/login" : "https://multiprobe.eusv.net/api/login", {
|
||||
method: "POST",
|
||||
body: `username=${encodeURIComponent(username.value)}&password=${encodeURIComponent(password.value)}`,
|
||||
headers: {
|
||||
|
@ -859,7 +825,7 @@ kbd {
|
|||
}
|
||||
|
||||
const openMenuButton = document.createElement("button");
|
||||
openMenuButton.style = "opacity:0.25;position:fixed;top:0px;right:0px;z-index:9999999;margin:4px;background-color:black;color:white;border:1px solid white;text-shadow: none!important;font-family: Arial,sans-serif;font-size: unset !important;";
|
||||
openMenuButton.style = "opacity:0.25;position:fixed;top:0px;right:0px;z-index:9999999;margin:4px;background-color:black;color:white;border:1px solid white";
|
||||
openMenuButton.innerText = "MultiProbe Menu";
|
||||
openMenuButton.onclick = () => {
|
||||
if (ws || localStorage["mpapikey"]) {
|
||||
|
@ -873,6 +839,4 @@ kbd {
|
|||
if (localStorage["mpapikey"] && localStorage["mpapikey"] !== "" && localStorage["mpconnectonload"] === "true") {
|
||||
doConnect(localStorage["mpapikey"]);
|
||||
}
|
||||
|
||||
console.log("[MP] Init complete.");
|
||||
})();
|
Loading…
Reference in a new issue