bypass censorship on scboy.cc

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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('完成,请勿对同一字符串重复操作!');
        });
    });
})();