scenexe2 utils v2

scenexe2 utilities.

// ==UserScript==
// @name         scenexe2 utils v2
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  scenexe2 utilities.
// @author       phosphorus
// @match        https://scenexe2.io/*
// @grant        none
// @license All Rights Reserved. This code is for personal, non-commercial use only. Modifications, redistributions, or unauthorized use are prohibited without explicit permission.
// ==/UserScript==

(async () => {

    (()=>{console.log("%c scenexe2 utils %c v2.1.2","font-size: 12px; font-weight: bold; color: #ffffff; background: #ff0000; padding: 5px;","font-size: 7.5px; font-weight: bold; color: #ff0000; background: #ffffff; padding: 5px;");})();

    const a = async (b) => {
        try {
            const c = await fetch(`https://expandedwater.online:3000/api/messages/${b}`, { cache: "force-cache" });
            return c.json();
        } catch (d) {}
    };

    const e = (f, g, h = document.body) => {
        const i = document.createElement(f);
        Object.assign(i.style, g);
        h.appendChild(i);
        return i;
    };

    const j = e("div", { position: "absolute", top: "10%", left: "10%", width: "300px", padding: "15px", border: "2px solid rgba(0, 255, 255, 0.8)", borderRadius: "10px", background: "radial-gradient(circle, rgba(0, 20, 40, 0.9), rgba(0, 10, 20, 0.95))", boxShadow: "0 0 20px rgba(0, 255, 255, 0.5)", fontFamily: "'Orbitron', sans-serif", color: "rgba(0, 255, 255, 0.9)", textShadow: "0 0 6px rgba(0, 255, 255, 0.8)", cursor: "grab" });

    const k = e("div", { marginBottom: "10px", padding: "5px", fontSize: "18px", fontWeight: "bold", textAlign: "center", borderBottom: "1px solid rgba(0, 255, 255, 0.5)", color: "rgba(0, 255, 255, 0.9)", textShadow: "0 0 5px rgba(0, 255, 255, 0.8)" }, j);

    let l = false, m = 0, n = 0;
    j.addEventListener("mousedown", (o) => { l = true; m = o.clientX - j.offsetLeft; n = o.clientY - j.offsetTop; j.style.cursor = "grabbing"; });
    document.addEventListener("mousemove", (p) => { if (l) { j.style.left = `${p.clientX - m}px`; j.style.top = `${p.clientY - n}px`; } });
    document.addEventListener("mouseup", () => { l = false; j.style.cursor = "grab"; });

    const q = (r, s) => {
        const t = document.getElementById(s) || e("div", { marginBottom: "7.5px", padding: "5px", background: "rgba(0, 0, 0, 0.5)", border: "1px solid rgba(0, 255, 255, 0.6)", borderRadius: "5px", color: "rgba(0, 255, 255, 0.9)", textShadow: "0 0 5px rgba(0, 255, 255, 0.8)" }, j);
        t.id = s; t.textContent = r;
    };

    const u = (v, w, x) => {
        const y = document.getElementById(w) || e("button", { margin: "5px 0", padding: "10px 15px", border: "1px solid rgba(0, 255, 255, 0.8)", borderRadius: "5px", background: "rgba(0, 20, 40, 0.8)", color: "rgba(0, 255, 255, 0.9)", fontFamily: "'Orbitron', sans-serif", fontSize: "14px", textShadow: "0 0 6px rgba(0, 255, 255, 0.8)", boxShadow: "0 0 12px rgba(0, 128, 255, 0.4)", cursor: "pointer", transition: "transform 0.2s ease, box-shadow 0.2s ease" }, j);
        y.id = w; y.textContent = v; y.onclick = x;
    };

    const z = (a1) => a1.match(/\]\sSpawned\sa\s(.+?)!/)?.[1];

    const a2 = (b1) => `${Math.floor(b1 / 60000)}m ${Math.floor(b1 / 1000) % 60}s`;

    const a3 = {
        a4: async () => {
            try {
                const b2 = (await a("1221635977987100874"))?.[0];
                if (!b2) return;

                const c2 = b2.content.match(/(top|bottom|left|right)/gi);
                const d2 = b2.content.match(/(\d+(\.\d+)?)\sminutes/);

                if (c2 && d2) {
                    const e2 = c2.slice(0, 2).map(f2 => f2.toLowerCase());
                    const g2 = parseFloat(d2[1]);
                    const h2 = b2.timestamp + g2 * 60 * 1000;

                    let i2;
                    const j2 = () => {
                        const k2 = h2 - Date.now();
                        if (k2 > 0) {
                            const l2 = a2(k2);
                            q(`Abyssal Gate opens in ${l2} (${e2.join(' ')})`, "abyss-timer");
                        } else {
                            q(`Abyssal Gate has already opened (${e2.join(' ')})`, "abyss-timer");
                            clearInterval(i2); a3.a4();
                        }
                    };

                    i2 = setInterval(j2, 1000);
                    j2();
                }
            } catch (e3) {
                console.error("Error in abyss:", e3);
            }
        },
        a5: async () => {
            const b3 = (await a("1187917859742027786"))[0];
            if (b3) {
                const c3 = Date.now() - b3.timestamp;
                q(`${z(b3.content)} (${a2(c3)} ago)`, "shape");
            }
        },
        a6: () => {
            k.textContent = `Welcome, ${window?.page?.state?.tankName || "Player"}`;
        },
        a7: () => {
            u("Reconnect", "reconnect-button", () => window.g());
        },
        a9: async () => {
            for (const b4 in a3) if (b4 !== "a9") await a3[b4]();
        }
    };

    let b5 = true;
    document.addEventListener("keydown", (c4) => {
        if (c4.code === "ShiftRight") {
            b5 = !b5;
            j.style.opacity = b5 ? "0" : "1";
            setTimeout(() => { j.style.display = b5 ? "none" : "block"; }, 500);
        }
    });

    setInterval(a3.a9, 1000);
})();