Greasy Fork is available in English.
移除B站推广视频广告
当前为
// ==UserScript==
// @name 屏蔽B站首页推荐广告
// @name:en Block Bilibili homepage ads
// @namespace http://tampermonkey.net/
// @version 1.3
// @description 移除B站推广视频广告
// @author RecycleBee
// @match *://www.bilibili.com/*
// @grant none
// @run-at document-end
// @license MIT
// @description:en remove Bilibili promoted video ads.
// ==/UserScript==
(function() {
'use strict';
function removeAds() {
document.querySelectorAll('.bili-video-card.is-rcmd').forEach(card => {
if (!card.classList.contains('enable-no-interest')) {
let placeholder = document.createElement("div");
placeholder.style.cssText = `
display: flex;
align-items: center;
justify-content: center;
width: 263.84px;
height: 148.4px;
background: #f4f4f4;
color: #888;
font-size: 14px;
font-weight: bold;
border-radius: 8px;
border: 1px dashed #ccc;
margin: auto;
`;
placeholder.innerText = "广告已屏蔽";
card.replaceWith(placeholder);
console.log("[Tampermonkey] 广告已屏蔽:", card);
}
});
}
removeAds();
let observer = new MutationObserver(() => removeAds());
observer.observe(document.body, { childList: true, subtree: true });
})();