每日牢骚:我不想过愚人节
本站不过愚人节,今天带来的是好用油猴脚本
如何不让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);
}
})();