帖子过滤

过滤帖子,仅适用于部分网站

As of 2020-03-17. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         帖子过滤
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  过滤帖子,仅适用于部分网站
// @author       AM
// @match        https://*/thread.php*
// @match        https://*/search.php*
// @grant        none
// ==/UserScript==

(function() {
    var divs = document.getElementsByTagName('div');
    for(var i = 0; i < divs.length; i++){
        if(divs[i].className == 't z'){
            tra(divs[i],1);
        }
        if(divs[i].id == 'main'){
            for(var a = 0; a<divs.length; a++){
                if(divs[a].className == 't'){
                    tra(divs[a],0);
                }
            }
        }
    }
    function tra(div_t,n){
        var htmla = div_t.innerHTML;
        var bc = '过滤词1|过滤词2|过滤词3';//通过 | 分隔开每个过滤词
        var reg;
        if(n==1){
            //reg = '/(<tr.align=\"center\" class=\"tr3.t_one\">[^+]*('+bc+').+?<\/tr>)/ig';
            reg = new RegExp( "(<tr.align=\"center\" class=\"tr3.t_one\">[^+]*("+bc+ ").+?<\/tr>)", "gi");
        }else{
            //reg = '/(<tr.class=\"tr3.tac\">[^+]*('+bc+').+?<\/tr>)/ig';
            reg = new RegExp( "(<tr.class=\"tr3.tac\">[^+]*("+bc+ ").+?<\/tr>)", "gi");
        }
        var tx = htmla.replace(reg,'');//<tr class="tr3 tac"><td></td><th>已屏蔽</th></tr>
        div_t.innerHTML =tx;
    }
})();