echou

你打字带空格

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         echou
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  你打字带空格
// @author       relic
// @match        https://bbs.sgamer.com/forum.php?mod=post*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.replace = function (text){
        text=text.replace(/\s*/g,"");
        var txt_split=text.split('');
        var arr = new Array();
        for(var index=0 ; index < txt_split.length;index++){
            arr.push(txt_split[index]);
            var reg=new RegExp("[\\u4E00-\\u9FFF]+","g");
            if(reg.test(txt_split[index])){
                arr.push(' ');
            }
        }
        var txt_new=arr.join('');
        return txt_new;
    }

    var z = document.getElementsByClassName("z");
    z[2].innerHTML+= "&nbsp;&nbsp;<a href='javascript:void(0);' onclick='echou()' > 恶臭</a>";

    window.echou=function () {
        var title = document.getElementById("subject");
        title.value=window.replace(title.value);
        var msg = document.getElementById('e_iframe').contentWindow.document.getElementsByTagName('body')[0];
        var str = msg.innerHTML;
        //str = str.replace(/<\/?[^>]*>/g,'');
        str=str.replace(/&nbsp;/ig,'');
        msg.innerHTML= window.replace(str);
    }
})();