
油猴插件:移除 Bilibili 直播/社情/电视剧 等推荐卡片
发现 bilibili 首页所有的卡片元素都是:
<div class="feed-card" /> <div class="bili-video-card is-rcmd enable-no-interest" /> <div class="floor-single-card" /> <div class="bili-video-card is-rcmd" /> 其中class="floor-single-card" 对应的卡片都是直播/电视剧/社情等内容,这种元素有个特征,就是内部会多两个 div 层级:
<div class="layer"></div> <div class="layer tiny"></div> 目前只能根据这个来排除社情/直播等内容,无法再细致化处理。
具体的脚本如下:
(function() { 'use strict'; function removeFloorSingleCards() { // class='floor-single-card' 的卡片全是直播/社情/电视剧等推荐,统统移除!!!! const cards = document.querySelectorAll('.floor-single-card'); cards.forEach(card => card.remove()); } // 初始调用以移除已有的卡片 removeFloorSingleCards(); // 使用 MutationObserver 监视 DOM 变化 const observer = new MutationObserver(removeFloorSingleCards); observer.observe(document.body, { childList: true, subtree: true }); })(); 更正确的做法应该是通过卡片封面调用 api 判断是否为社情才对,直接这么处理不够细致,先这么使用吧~
1 chipipi 2024-10-09 16:56:01 +08:00 好像不起作用,摸鱼滑评论边小窗看视频,底部有个社情直播卡片真的有点尬 |
2 magicianlib OP @chipipi 这个只针对 B 站首页有效,我发现对我很有用 |