吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2212|回复: 55
收起左侧

[其他原创] 哔哩哔哩首页去广告

[复制链接]
梦汐 发表于 2023-7-10 23:58
油猴脚本
[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name        哔哩哔哩首页去广告
// @namespace   Violentmonkey Scripts
// @match       *://www.bilibili.com/
// @require     https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==
const observer = new MutationObserver((mutationsList, observer) => {
    // 遍历每一个发生变化的 mutation
    for (let mutation of mutationsList) {
        // 检查新增元素
        if (mutation.type === 'childList') {
            // 遍历新增的节点和子节点
            mutation.addedNodes.forEach(node => {
                if ($(node).is('.bili-video-card.is-rcmd') || $(node).is('.feed-card')) {
                    handleNode(node);
                }
            });
        }
    }
});

// 要监视的目标节点
const targetNode = document.body;

// 配置并启动 MutationObserver
const config = { childList: true, subtree: true };
observer.observe(targetNode, config);

// 处理新增的节点的函数
function handleNode(node) {
    if (node.marking) {
        return null
    }
    let element = $(node).find("div>a")[0]
    if (!element.getAttribute('href').includes("www.bilibili.com")) {
        node.marking = true
        if ($(node.parentElement).is('.feed-card')) {
            node.parentElement.parentElement.appendChild(node.parentElement);
        } else {
            node.parentElement.appendChild(node);
        }
        console.log("移除广告", node);

    }
}
$(
    function () {
        $('.bili-video-card.is-rcmd').each(function () {
            handleNode(this)
        });
    }
)

免费评分

参与人数 11吾爱币 +17 热心值 +10 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
ma2678 + 1 + 1 我很赞同!
zhangxu05180 + 1 + 1 谢谢@Thanks!
ichinose + 1 用心讨论,共获提升!
dd52 + 1 + 1 谢谢@Thanks!
sht281 + 1 + 1 谢谢@Thanks!
skiss + 1 + 1 谢谢@Thanks!
Stap + 1 + 1 谢谢@Thanks!
woyucheng + 1 + 1 谢谢@Thanks!
zhujs47 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
回忆扣心弦 + 1 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

darksetyaer 发表于 2023-7-11 00:54
去了广告b站更没钱了
xwawa 发表于 2023-7-11 07:42
xiaofeiTM233 发表于 2023-7-11 06:13
功能还是太简陋了
这边有更优选:Bilibili Evolved
https://github.com/the1812/Bilibili-Evolved
一只小凡凡 发表于 2023-7-11 00:02
感觉没有必要,就连视频广告它都不加,就加个首页广告,广告内容也没有让人不适
pbgz 发表于 2023-7-11 00:26
支持一下 有微博吗?大部分脚本都不支持新版!
rosewood 发表于 2023-7-11 03:29
好东西,可以让b站强制回归初心(指宁倒闭不变质)
xwawa 发表于 2023-7-11 06:41
xiaofeiTM233 发表于 2023-7-11 06:13
功能还是太简陋了
这边有更优选:Bilibili Evolved
https://github.com/the1812/Bilibili-Evolved

谢谢推荐,看看!
tzlqjyx 发表于 2023-7-11 07:06
B站广告确实多,学习了
shiquda 发表于 2023-7-11 07:25
广告也可以用浏览器插件过滤,比如https://adguard.com/zh_cn/welcome.html
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-14 13:54

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表