绕过 CoCo 作品分享的审核机制,让他人可以看到你分享的作品,请低调使用
目前為
// ==UserScript==
// @name CoCo 作品分享审核绕过
// @namespace https://slightning.rechen.xyz/
// @version 0.1.0
// @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 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 = function() {
var fileContent = JSON.parse(this.result)
fileContent.unsafeExtensionWidgetList.forEach(function(unsafeExtension) {
var safeExtension = {
id: Math.floor(Math.random() * 1000),
type: unsafeExtension.type.substring(7),
cdnUrl: `data:text/plain;charset=UTF-8,${encodeURIComponent(unsafeExtension.code)}//`
}
fileContent.blockCode = fileContent.blockCode.replaceAll(`"${unsafeExtension.type}"`, `"${safeExtension.type}"`)
fileContent.extensionWidgetList.push(safeExtension)
})
fileContent.unsafeExtensionWidgetList = []
Object.keys(fileContent.widgetMap).forEach(function(key) {
if (key.startsWith("UNSAFE_")) {
var widget = fileContent.widgetMap[key]
delete fileContent.widgetMap[key]
var id = key.substring(7)
fileContent.widgetMap[id] = widget
fileContent.blockCode = fileContent.blockCode.replaceAll(`"${key}"`, `"${id}"`)
widget.id = id
widget.type = widget.type.substring(7)
}
})
delete fileContent.blockJsonMap
console.log(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)
originalSend.apply(xhr, xhrArguments)
}
} else {
originalSend.apply(this, arguments)
}
} else {
originalSend.apply(this, arguments)
}
}
})();