Greasy Fork

Greasy Fork is available in English.

编程猫防屏蔽防吃格式助手

编程猫发帖防屏蔽防吃格式

当前为 2022-07-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         编程猫防屏蔽防吃格式助手
// @namespace    https://shequ.codemao.cn/user/201649362
// @version      0.4
// @description  编程猫发帖防屏蔽防吃格式
// @author       SMYLuke
// @match        https://shequ.codemao.cn/community
// @match        https://shequ.codemao.cn/community?board=*
// @match        https://shequ.codemao.cn/community/*
// @icon         https://cdn-community.codemao.cn/47/community/d2ViXzUwMDFfNjI5MDU1XzIyOF8xNjI2NDMyNDQwMDE0XzRlYWZmNzBk.png
// @grant        GM_xmlhttpRequest
// @grant        GM_log
// @grant        GM_getValue
// @grant        GM_setValue
// @connect      static.box3.codemao.cn
// @require      https://cdn.jsdelivr.net/npm/[email protected]
// @license MIT
// ==/UserScript==

async function waitElement(selector) {
    'use strict';
    let el;
    while (!el) {
        el = document.querySelector(selector);
        await new Promise(requestAnimationFrame);
    }
    return el;
}
(async () => {
    'use strict';
    let link = document.createElement("link");
    link.rel = "stylesheet";
    link.type = "text/css";
    link.href = "https://unpkg.com/[email protected]/dist/css/mdui.min.css";
    document.head.appendChild(link);
    var doNotShield = {
        run: async () => {
            const content = (await waitElement(textarea)).contentDocument.body;
            const data = `<!DOCTYPE HTML>
<html lang="ch-Zh">
<head>
    <meta charset="utf-8">
    <link href="https://static.codemao.cn/community/prism/prism.min.css" rel="stylesheet" type="text/css" />
    <script>onload = () => {document.body.innerHTML = decodeURI(document.body.innerHTML)}</script>
</head>
<body>
${encodeURI(content.innerHTML)}
</body>
</html>`;
            GM_xmlhttpRequest({
                method: "post",
                url: "https://static.box3.codemao.cn/block",
                data: data,
                binary: true,
                async onload({ response }) {
                    (await waitElement(textarea)).contentDocument.body.innerHTML = `<iframe src="//static.box3.codemao.cn/block/${JSON.parse(response).Key}.html" style="width: 640px; height: 480px; display: block; margin: 40px auto; max-width: 100%;"></iframe>`;
                },
            });
        }
    };
    const textarea = "#react-tinymce-0_ifr";
    if (/community?board=\d+|community$/.test(location.href)) {
        (await waitElement("#root > div > div.r-index--main_cont > div > div.r-community--right_search_container > div > div.r-community--search_header > a.r-community--send_btn")).addEventListener("click", () => {
            window.gui = new lil.GUI({title: "编程猫防屏蔽助手"});
            window.gui.domElement.style.top = "unset";
            window.gui.domElement.style.bottom = "0";
            window.gui.domElement.style.userSelect = "none";
            window.gui.add(doNotShield, "run").name("使用防屏蔽功能");
        });
        (await waitElement("#root > div > div.r-index--main_cont > div > div:nth-child(4) > div > div.c-model_box--content_wrap > div > a")).contenDocument.body.addEventListener("click", () => {
            window.gui.destroy();
        });
    } else {
        // 此处没有写好。
    };
})();