bypass censorship on scboy.cc

Allow to post forbidden words on thread create & reply page.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         bypass censorship on scboy.cc
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Allow to post forbidden words on thread create & reply page.
// @author       tianyi
// @include      https://www.scboy.cc/*
// ==/UserScript==

(function() {
    'use strict';
    $(function() {
        if (window.location.href.indexOf('post-create-') === -1 && window.location.href.indexOf('post-update-') === -1 && window.location.href.indexOf('thread-create-') === -1) {
            return;
        }

        let $btn = $(`<div class="edui-box edui-button edui-default">
            <div class="edui-default">
                <div class="edui-button-wrap edui-default">
                    <div  unselectable="on" title="敏感词" class="edui-button-body edui-default">
                        <div class="edui-box edui-default">敏</div>
                    </div>
                </div>
            </div>
        </div>`).appendTo('.edui-toolbar');

        $btn.click(function() {
            var sel = ue.selection;
            var range = sel.getRange();
            var parent = sel.getStart();
            var content;

            if (range.startOffset === range.endOffset) {
                return;
            }

            content = parent.textContent;    /* warning: undefined behaviour if $parent contains non-text child nodes */
            content = content.slice(0, range.startOffset + 1) + '<strong class="valid-feedback" style="display: none;">#</strong>' + content.slice(range.startOffset + 1);
            parent.innerHTML = content;
            alert('完成,请勿对同一字符串重复操作!');
        });
    });
})();