Greasy Fork is available in English.

B站哔哩哔哩删除动态右边标签话题新闻元素

哔哩哔哩右边的标签话题真是睿智,眼不见为净!

// ==UserScript==
// @name         B站哔哩哔哩删除动态右边标签话题新闻元素
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  哔哩哔哩右边的标签话题真是睿智,眼不见为净!
// @author       OrangePig
// @match        *://t.bilibili.com/*
// @match        *://www.bilibili.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant        none
// @license MIT
// ==/UserScript==


(function () {
         'use strict';

    //顺便删了adblock提醒关闭tip
    var adblockTips = document.getElementsByClassName('adblock-tips')[0]
    if (adblockTips != null) {
        adblockTips.style.display = 'none';
    }

    //由于是异步加载,监测DOM删的
    const handleObserveEvent = (records) => {
        records
            .flatMap((r) => [...r.addedNodes])
            .filter((n) => n.classList?.contains('topic-panel'))
            .forEach((n) => n.remove());
    };

    const app = document.querySelector('#app');
    const ob = new MutationObserver(handleObserveEvent);

    ob.observe(app, {
        subtree: true,
        childList: true,
    });

    deleteShit();
    setTimeout(function () { deleteShit(); }, 100);
    setTimeout(function () { deleteShit(); }, 2000);
    //没有监测DOM,懒得注释掉了
    function deleteShit() {
        let bilibiliPanels = document.getElementsByClassName('relevant-topic')
        if (bilibiliPanels.length != 0) {
            for (let i = 0; i < bilibiliPanels.length; i++) {
                bilibiliPanels[i].style.display = 'none';
            }

        }

        var bilibiliPanel = document.getElementsByClassName('topic-panel')[0]
        if (bilibiliPanel != null) {
            bilibiliPanel.style.display = 'none';
        }

    };
})();