Greasy Fork

Greasy Fork is available in English.

去你妈的批站诈骗广告

bilibili,B站 屏蔽首页小火箭推广广告

目前为 2025-01-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         去你妈的批站诈骗广告
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  bilibili,B站 屏蔽首页小火箭推广广告
// @author       爆菊大师
// @match        *://*.bilibili.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';
    function checkPseudoElements() {
        const cards = document.querySelectorAll('.bili-video-card.is-rcmd');
        cards.forEach((card) => {
            const beforeContent = window.getComputedStyle(card, '::before').content;
            if (beforeContent.includes('该内容被AdGuard/AdBlock类插件屏蔽')) {
                card.style.display = 'none';
            }
        });
    }
    function checkIcons() {
        const imageLinks = document.querySelectorAll('.bili-video-card__image--link');
        imageLinks.forEach((link) => {
            const targetIcon = link.querySelector('.vui_icon.bili-video-card__stats--icon');
            if (targetIcon) {
                link.closest('.bili-video-card').style.display = 'none';
            }
        });
    }
    checkPseudoElements();
    checkIcons();
    const observer = new MutationObserver(() => {
        checkPseudoElements();
        checkIcons();
    });
    observer.observe(document.body, { childList: true, subtree: true });
})();