屏蔽百度热搜、资讯、搜索页右侧相关网站、热榜

屏蔽百度热搜、百度首页资讯、百度首页热榜、百度搜索页右侧相关网站.

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 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.7
// @description  屏蔽百度热搜、百度首页资讯、百度首页热榜、百度搜索页右侧相关网站.
// @author       ysypnbh
// @match        *://www.baidu.com/*
// @grant        none
// ==/UserScript==
(function () {
    'use strict';
    // 未登录,关闭百度首页热榜
    if (document.getElementById("s-hotsearch-wrapper")) {
        document.getElementById("s-hotsearch-wrapper").className += ' hide'
    }
    if (document.getElementById("head_wrapper")) {
        document.getElementById("head_wrapper").className += ' s-ps-islite'
    }
    // 已登录,关闭百度首页资讯
    if (document.getElementsByClassName("s-manhattan-index")) {
        document.getElementsByClassName("s-manhattan-index").className += ' is-lite'
    }
    if (document.getElementById("s_menu_gurd")) {
        document.getElementById("s_menu_gurd").style.display = 'none'
    }
    if (document.getElementById("s_wrap")) {
        document.getElementById("s_wrap").style.display = 'none'
    }
    // 已登录,关闭百度placeholder
    setTimeout(() => {
        // 已登录,关闭百度placeholder
        if (document.getElementById('kw')) {
            let kw_elem = document.getElementById("kw");
            if (kw_elem.hasAttribute("placeholder")) {
                document.getElementById('kw').setAttribute('placeholder', '');
            }
        }
        if (document.getElementById('chat-textarea')) {
            let chat_textarea_elem = document.getElementById("chat-textarea");
            if (chat_textarea_elem.hasAttribute("placeholder")) {
                document.getElementById('chat-textarea').setAttribute('placeholder', '');
            }
        }
    }, 1000);


    function closeContentRight() {
        if (location.hostname == "www.baidu.com") {
            var myVar = setInterval(function () {
                // 屏蔽百度搜closeContentRight索页右侧相关网站、百度热榜等
                if (document.getElementById('content_right')) {
                    document.getElementById('content_right').style.display = "none";
                }
                if (document.getElementById('rrecom-container')) {
                    document.getElementById('rrecom-container').style.display = "none";
                }
                if (document.getElementsByClassName("opr-recommends-merge-content")[0]) {
                    document.getElementsByClassName("opr-recommends-merge-content")[0].style.display = "none";
                }
                // popup-advert 关闭华为广告 制作屏蔽该广告日期25-11-18
                if (document.getElementsByClassName("popup-advert")[0]) {
                    document.getElementsByClassName("popup-advert")[0].style.display = 'none'
                }
                // 清除placeholder缓存
                if (localStorage.getItem('placeholderData')) {
                    localStorage.removeItem('placeholderData');
                }
            }, 150);
        }
    }
    closeContentRight()
    // Your code here...
})();