Bilibili 去除推广区域

去除新版首页的推广区域和赛事区域

// ==UserScript==
// @name         Bilibili 去除推广区域
// @version      0.3
// @description  去除新版首页的推广区域和赛事区域
// @author       monat151
// @match        https://www.bilibili.com/
// @match        https://www.bilibili.com/?spm_id_from=*
// @grant        none
// @namespace https://greasyfork.org/users/325815
// ==/UserScript==

(function() {
    'use strict';

    // window.nanoWidgetsJsonp = {};

    var retry_count = 0
    function act() {
        if (retry_count > 150) {
            console.error('action failed and retry count goes to its limit.')
            return;
        }
        const _1 = document.getElementsByClassName('eva-extension-area')[0]?.parentElement
        const _2 = document.getElementsByClassName('bili-grid no-margin')[0]
        const _3 = document.getElementsByClassName('bili-grid')[3]

        const _o1 = document.getElementsByClassName('ant-btn css-157caa6 ant-btn-default  css-l4670w')[0]?.parentElement
        if (_1 && _2 && _3) {
            _1.style = _2.style = _3.style = 'display:none;'
            window.monatRemoved = true
            window.recoverMonatRemoveAct = () => {
                _1.style = _2.style = _3.style = window.monatRemoved ? '' : 'display:none;'
                window.monatRemoved = !window.monatRemoved
            }

            const new_button = document.createElement('button');
            new_button.className = 'ant-btn css-157caa6 ant-btn-default  css-l4670w';
            new_button.innerHTML = `显示/隐藏推广元素`;
            new_button.addEventListener('click', (e) => {
                window.recoverMonatRemoveAct()
            });
            if (_o1)
                _o1.after(new_button);
        } else {
            setTimeout(()=>{ act() },50)
            retry_count++;
        }
    }

    setTimeout(()=>{
        act()
    },50);
})();