splix-js-demodularizer

A vile trick that may aid you in executing your beloved scripts in the novel version of the client

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/478491/1673567/splix-js-demodularizer.js

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         splix-js-demodularizer
// @namespace    http://tampermonkey.net/
// @version      0.2.5
// @description  A vile trick that may aid you in executing your beloved scripts in the novel version of the client
// @author       You
// @match        https://splix.io/
// @grant        none
// @run-at       document-start
// ==/UserScript==

await(async function () {
    if (document.location.pathname !== "/") return;

    const verToInt = v => v.split(".").reduce((acc, n, i) => acc + parseInt(n) * Math.pow(100, 2 - i), 0)
    const getDemodVer = text => text?.match(/@version\s+(\d+\.\d+\.\d+)/)?.[1] || "0.0.0"
    const currentVersion = "0.2.5";

    if (verToInt(getDemodVer(localStorage.clientDemodCode)) > verToInt(currentVersion)) {
        await (new Function("return (async () => { " + localStorage.clientDemodCode + " })()"))()
    } else {
        if (localStorage.clientCode && !window.jsDemodularized && ![...document.scripts].some(s => s.innerText.includes("globalThis.IS_DEV_BUILD"))) {
            document.open("text/html")
            document.write(localStorage.clientCode)
            document.close()
            window.jsDemodularized = true
        }
        if (!window.locked) {
            async function bundleJS(url, visited = new Set()) {
                if (visited.has(url)) return ""
                visited.add(url)

                let response = await fetch(url + `?v=${Math.floor(Date.now() / 300000)}`)
                if (!response.ok) throw new Error(`Response status: ${response.status}, URL: ${url}`)
                let script = (await response.text()).replaceAll(/\bexport\b/g, "")

                const importRegex = /^import[\s\S]*?["'](.*)["'].*$/gm
                let match
                let result = script
                while ((match = importRegex.exec(script)) !== null) {
                    const importPath = match[1]
                    let importedCode
                    if (importPath.includes('deps/')) {
                        const parts = importPath.replace('../../deps/', '').split('/')
                        const cdnUrl = `https://cdn.jsdelivr.net/npm/@adlad/${parts[0].replace('adlad-', '')}@${parts[1]}/${parts.slice(2).join('/')}`
                        importedCode = await bundleJS(cdnUrl, visited)
                    } else if (importPath.startsWith('.')) {
                        importedCode = await bundleJS(new URL(importPath, url).toString(), visited)
                    }
                    result = result.replace(match[0], importedCode)
                }
                return result
            }

            window.locked = true;
            const loadScript = fetch(
                `https://update.greatest.deepsurf.us/scripts/478491/splix-js-demodularizer.js?v=${Math.floor(Date.now() / 3600000)}`
            ).then(r => r.text()).catch(() => null);

            let isUpdated = false;
            if (
                localStorage.setItem("demodularizerVersion", "0.2.3") ||
                verToInt(localStorage.clientCode?.match(/@demod.*?\sv:(\d+\.\d+\.\d+)/)?.[1] || "0.0.0") < verToInt(currentVersion) ||
                Math.floor(Date.now() / 3600000) !== Math.floor((parseInt(localStorage.clientCode?.match(/@demod.*?\sts:(\d+)/)?.[1]) || 0) / 3600000)
            ) {
                const clientPath = "https://raw.githubusercontent.com/jespertheend/splix/refs/heads/main/client/"
                const bundled = (await bundleJS(clientPath + "src/main.js"))
                    .replaceAll(/\s\ss\S+(\S)\S\1\S\1\S*s\S*/gm, "")
                    .replace(/IS_DEV_BUILD\s*=\s*true/, "IS_DEV_BUILD = false") +
                    `\n/* @demod v:${currentVersion} ts:${Date.now()} */`

                localStorage.clientCode = (await (await fetch(clientPath + "index.html")).text())
                    .replace(/<script.*?\/main.*?<\/script>/, "")
                    .replace("</body>", `<script>${bundled}</script></body>`)

                isUpdated = true;
            }

            try {
                const latest = await loadScript;
                if (latest) {
                    const version = getDemodVer(latest);
                    const prevVersion = getDemodVer(localStorage.clientDemodCode);
                    if (version) {
                        localStorage.clientDemodCode = latest
                        if (verToInt(version) > verToInt(prevVersion)) {
                            isUpdated = true;
                            localStorage.removeItem('clientCode');
                        }
                    }
                }
            } catch { }

            if (isUpdated) {
                console.clear();
                location.reload();
            }
        }
    }
})();