Greasy Fork is available in English.

8080.net极速论坛屏蔽某人帖子和回复

屏蔽一些烦人的ID,这次重写了一下,增加了回帖屏蔽功能.另外也屏蔽了8080论坛安全跳转.

// ==UserScript==

// @name         8080.net极速论坛屏蔽某人帖子和回复

// @namespace    http://tampermonkey.net/

// @version      3.7

// @description  屏蔽一些烦人的ID,这次重写了一下,增加了回帖屏蔽功能.另外也屏蔽了8080论坛安全跳转.

// @author       noxin

// @match        https://bbs.8080.net/*

// @grant        none
// @require      https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @run-at document-start
// ==/UserScript==



(function() {

    'use strict';

    //下面写要屏蔽的用户名,多个用户名中间用|隔开
    var re = new RegExp("我爱晕鹿|xxxx|梅山郭富城|台湾省主席|主的信使");


    var jq = jQuery.noConflict();


    //增加屏蔽安全跳转
    // var highestTimeoutId = setTimeout(";");
    // for (var i = 0; i < highestTimeoutId; i++) {
    //     clearTimeout(i);
    // }


    let originalReady = window.ready;
    const fakeReady = (...args) => {
        if (args[0] instanceof Function && args[0].toString().indexOf('topic-unsafe-internet-environment') >= 0) {
            console.log('prevent redirect');
            return;
        }
        originalReady.apply(window, args);
    };
    if (originalReady) {
        window.ready = fakeReady;
    } else {
        Object.defineProperty(window, 'ready', {
            get() {
                return fakeReady;
            },
            set(val) {
                return originalReady = val;
            }
        });
    }



   
    var k = 0;

    function appendStyle(styles) {
        var css = document.createElement('style');
        css.type = 'text/css';

        if (css.styleSheet) css.styleSheet.cssText = styles;
        else css.appendChild(document.createTextNode(styles));

        document.getElementsByTagName("head")[0].appendChild(css);
    }
    var styles = '.tmphide { display:none; } #showhidepost{position:fixed;bottom:2px;right:2px;font-size:12px;color:#EBE8E8;}#showhidepost:hover{color:#333}.flag0{background:#fbf5f5}';
    appendStyle(styles);

    jq(document).ready(function(jq) {
        //新版 ,jQuery操作,把回复也隐藏
        //主题页
        jq("#moderate tbody").filter(function(index) {
            if (re.test(jq(this).find(".by:eq(0) cite").text())) {
                k++;
                return true;
            } else {
                return false;
            }
        }).addClass('tmphide flag0');

        //回复列表
        jq("#postlist>div").filter(function(index) {
            if (re.test(jq(this).find(".username").text())) {
                k++;
                return true;
            } else {
                return false;
            }
        }).addClass('tmphide flag0');

        //恢复显示
        console.log('共屏蔽了' + k + "条");
        if (k > 0) {
            var reval = "";
            reval += "    function showall(){";
            reval += "        jq('.flag0').toggleClass('tmphide')";
            reval += "    }";

            jq('<script>' + reval + '</script>').appendTo('body')
            jq('<a href="javascript:;" id="showhidepost">显示屏蔽的' + k + '条</a>').appendTo('body');
            var oritext = jq('#showhidepost').text();
            console.log("oritext:" + oritext);
        }
        jq(document).on('click', '#showhidepost', function(event) {
            jq('.flag0').toggleClass('tmphide');
            jq('.flag0').get(0).scrollIntoView({
                behavior: 'smooth',
                block: 'center'
            });
            if (jq('#showhidepost').text() == oritext) {
                jq('#showhidepost').text('重新隐藏')
            } else {
                jq('#showhidepost').text(oritext)
            }
        });
    });



})();