百度首页净化

过滤或屏蔽百度首页政治宣传(需编辑代码内关键词列表)

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         百度首页净化
// @namespace    妖伊社
// @version      0.1
// @description  过滤或屏蔽百度首页政治宣传(需编辑代码内关键词列表)
// @author       妖伊社
// @match        https://www.baidu.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        unsafeWindow
// @license      MIT
// ==/UserScript==
 
(function() {
    'use strict';
    //修改这两个关键词列表,以添加你想屏蔽的关键词或作者
    var banTitle = ["美国", "白宫", "中国", "大国", "央视"]
    var banAuthor = ["环球", "新华", "观察者网","胡锡进"]
    var banEverything = false; //如希望隐藏所有新闻,请改为true
 
    function BaiduSM(){
        var i = 0;
        var j = 0;
        var comment = "";
 
        if(banEverything){
            document.getElementById("s_wrap").style.display = "none";
            return;
        }
 
        var c = document.getElementsByClassName("s-news-item-title c-link c-font-big");
        for (i=0; i < c.length; i++)
        {
            try
            {
                comment = c[i].innerHTML;
                for(j=0; j < banTitle.length; j++){
                    if(comment.match(banTitle[j]).length > 0){
                        c[i].parentNode.parentNode.parentNode.innerHTML = "(此新闻标题含关键词“" + banTitle[j] + "”已被屏蔽)";
                    }
                }
            }catch (e){
                continue;
            }
        }
 
        var t = document.getElementsByClassName("c-gap-right c-color-gray");
        for (i=0; i < c.length; i++)
        {
            try
            {
                comment = t[i].innerHTML;
                for(j=0; j < banAuthor.length; j++){
                    if(comment.match(banAuthor[j]).length > 0){
                        t[i].parentNode.parentNode.parentNode.innerHTML = "(此新闻由“" + banAuthor[j] + "”创作已被屏蔽)";
                    }
                }
            }catch (e){
                continue;
            }
        }
        setTimeout(function(){ BaiduSM(); }, 1000);
    }
 
    BaiduSM();
})();