s-j-d

sjd module

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.sleazyfork.org/scripts/548054/1654841/s-j-d.js

// ==UserScript==
// @name         s-j-d
// @namespace    http://tampermonkey.net/
// @version      0.1.11
// @description  sjd module
// @author       You
// @match        https://splix.io/
// @grant        none
// @run-at       document-start
// ==/UserScript==

await(async function () {
    const verToInt = v => v.split(".").reduce((acc, n, i) => acc + parseInt(n) * Math.pow(100, 2 - i), 0)
    const isAlreadyInjected = () => window.jsDemodularized || [...document.scripts].some(s => s.innerText.includes("globalThis.IS_DEV_BUILD"))
    const getStorageVersion = () => localStorage.clientCode?.match(/@demod.*?\sv:(\d+\.\d+\.\d+)/)?.[1] || "0.0.0"
    const isStorageActual = () => Math.abs(Date.now() - (parseInt(localStorage.clientCode?.match(/@demod.*?\sts:(\d+)/)?.[1]) || 0)) < 24 * 60 * 60 * 1000

    const currentVersion = "0.1.11"; localStorage.demodularizerVersion = "0.2.3"
    console.log("1")
    if ((isAlreadyInjected() && isStorageActual()) || document.location.pathname !== "/") return
    console.log("2")
    if (localStorage.clientCode && isStorageActual()) {
        inject()
    } else {
        await bundle()
        location.reload()
    }

    function inject() {
        console.log("3")
        document.open("text/html")
        document.write(localStorage.clientCode)
        document.close()
        window.jsDemodularized = true
    }

    async function bundle() {
        console.log("4")
        let latest, version
        try {
            latest = (await (await fetch(`https://update.greasyfork.org/scripts/548054/s-j-d.js?v=${Date.now()}`)).text())
            version = latest.match(/@version\s+(\d+\.\d+\.\d+)/)?.[1] || "0.0.0"
        } catch { }

        if (latest && version && verToInt(version) > verToInt(currentVersion)) {
            await (new Function("return (async () => { " + latest + " })()"))()
        } else {
            if (verToInt(getStorageVersion()) > verToInt(currentVersion)) {
                inject()
            } else {
                async function bundleJS(url, visited = new Set()) {
                    if (visited.has(url)) return ""
                    visited.add(url)

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

                    const importRegex = /^import.*["'](.*)["'].*$/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.stop()
                const clientPath = "https://raw.githubusercontent.com/jespertheend/splix/refs/heads/main/client/"
                const bundled = (await bundleJS(clientPath + "src/main.js"))
                    .replaceAll(/((\S)(\S)\3\2\S+(s)\S+\4\S+\4\S+)\d/g, "$14")
                    .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>`)
            }
        }
    }
})();