根据关键字屏蔽微博

屏蔽带有关键字的微博/用户/评论, 新增屏蔽广告/右侧主播明星推荐/左下播放器/右下网页聊天/屏蔽巨幅背景图片广告

目前為 2017-02-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name 根据关键字屏蔽微博
// @namespace Blockweibo
// @include http://weibo.com/*
// @author  http://weibo.com/chainjoy
// @version 1.3
// @description 屏蔽带有关键字的微博/用户/评论, 新增屏蔽广告/右侧主播明星推荐/左下播放器/右下网页聊天/屏蔽巨幅背景图片广告
// @require  https://code.jquery.com/jquery-2.2.4.min.js
// @grant  GM_addStyle
// ==/UserScript==

//===   关键字名单 ===//

var List = "金正男||北京厨子||习近";

// 以下请勿修改
GM_addStyle(
    'div[feedtype=ad], ' +
    '#Pl_Core_ThirdHtmlData__77,' +
    '#Pl_Core_ThirdHtmlData__76, ' +
    '#v6_pl_ad_bottomtip, .PCD_mplayer,  ' +
    '#WB_webim, #v6_pl_content_biztips, ' +
    '#v6_pl_rightmod_rank, ' +
    '#v6_pl_rightmod_ads35, ' +
    '#v6_pl_rightmod_ads36, ' +
    ' #v6_trustPagelet_recom_member,  ' +
    '#v6_pl_rightmod_noticeboard{ display:none; } ' +
    '.WB_main_c .send_weibo .input {border: 1px solid #ddd; }' +
    '.WB_miniblog{ padding-top:40px;background:#BFE4EB;background-image: none;}'
);
(function ($, undefined) {
    $(function () {
        var x = List.split("||");
        mo = new MutationObserver(function(allmutations) {
            $(".WB_text, .WB_info").each(block);
        });
        var targets = document.body;
        mo.observe(targets, {'childList': true,'characterData':true,'subtree': true});
        function block(){
            var txt = $(this).text();
            if(findwords(txt) === true){
                $(this).text('... ... ... ... ...');
                $(this).parent().find('.WB_media_wrap, .WB_tag_rec').remove();
                if($(this).hasClass('WB_info')){
                    $(this).parent().text('... ... ... ... ...');
                }
            }
        }
        function findwords(ele){
            var result = (ele.indexOf(x[0]) > -1);
            for(var i = 1; i <= x.length; i++){
                result = result || (ele.indexOf(x[i]) > - 1);
            }
            return result;
        }
        
        // end
    });
})(window.jQuery.noConflict(true));