Greasy Fork

Greasy Fork is available in English.

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

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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...
})();