每日牢骚:我不想过愚人节

本站不过愚人节,今天带来的是好用油猴脚本
如何不让B站网页版在愚人节的时候打扰到你(需要用旧版网页端)

不保证明年还能正常运行,但至少今年可以

代码如下:

(function() {
    'use strict';

    const changeColor = () => {
        document.querySelectorAll('span.bili-dyn-title__text').forEach((e) => {
            if(e.style.color=='rgb(109, 199, 129)'){
                e.style.color='rgb(251, 114, 153)'
            }
        })
        document.querySelectorAll('div.b-avatar__layer__res.local-1').forEach((e) => {
            e.style.display = 'none';
        })
    }

    const isTodaySpecificDate = (month, day) => {
        const today = new Date();
        return today.getMonth() + 1 === month && today.getDate() === day;
    }

    const observer = new MutationObserver((mutationsList, observer) => {
        for (let mutation of mutationsList) {
            if (mutation.type === 'childList') {
                const targetElement = document.querySelector('span.bili-dyn-title__text');
                if (targetElement) {
                    console.log("span出现");
                    changeColor();
                    break;
                }
            }
        }
    });

    if(isTodaySpecificDate(4,1)){
        //是愚人节当天才会运行
        const config = { childList: true, subtree: true };
        observer.observe(document.body, config);
    }

})();

木头箱子脆脆,但是这样正好

如无特殊声明,本站内容均遵循 CC BY-NC-SA 4.0 协议

转载请注明出处并保留作者信息,谢谢!

none
最后修改于:2025年04月01日 00:55

添加新评论

提醒:站长手头紧,没有配备『评论回复邮件提醒』功能
评论后,劳烦您隔一段时间回到本页面查看站长回复(一般都会回)