Greasy Fork is available in English.

移除B站热搜框

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

Od 22.08.2021.. Pogledajte najnovija verzija.

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

(function () {
    let app = document.getElementById("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.style.display = "none"
                        mutationObserver.takeRecords();
                    }
                }
            }
        });
    });
    //监听dom节点变化
    mutationObserver.observe(app,config);

})();