Greasy Fork

Greasy Fork is available in English.

移除B站热搜框

你如果不喜欢热搜信息可以移除它了

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         移除B站热搜框
// @namespace    http://tampermonkey.net/
// @version      1.2
// @match        *://www.bilibili.com/
// @match        *://*.bilibili.com/*
// @match        *://*.bilibili.com/video/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @description  你如果不喜欢热搜信息可以移除它了
// ==/UserScript==

(function () {
    let app;
    let url = window.location.href;
    let idnexof = url.indexOf("history");
    if( idnexof != -1){
        //历史界面
        app=document.getElementById("internationalHeader");
    }

    else{
        if(app == null){
            //主页面
            app = document.getElementById("app");
            if (app == null){
                //登录页面
                app = document.getElementById("login-app");
                if(app == null){
                    return
                }
            }
        }

    }
    //设置监听dom改变类型
    let config = {
        //子节点
        "childList":true,
        //后代节点
        "subtree":true
    };

    let mutationObserver = new MutationObserver(function (records,mutationObserver){
        records.forEach(function (record) {
            for (let i = 0;i<record.addedNodes.length;i++){
                let node = record.addedNodes[i];
                //判断是否是HTML节点
                if (node.nodeType == 1) {
                    //找到热搜所在的节点
                    if (node.getAttribute("class") == "trending" || node.getAttribute("class") == "ad-report report-wrap-module report-scroll-module" || node.getAttribute("class") == "ad-report ad-floor report-wrap-module report-scroll-module" ) {
                        //设为隐藏
                        node.style.display = "none"
                    }
                }
            }
        });
    });
    //监听dom节点变化
    mutationObserver.observe(app,config);

})();