V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
xidianlz
V2EX  ›  分享创造

b 站黑神话防剧透插件

  •  
  •   xidianlz · 49 天前 · 2162 次点击
    这是一个创建于 49 天前的主题,其中的信息可能已经有所发展或是发生改变。

    黑神话悟空上线之后 b 站的推荐简直没法看。一不小心就被剧透。所以做了这个油猴插件。 需要先安装 https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo

    安装后之后

    把下面的代码粘贴进去。

    // ==UserScript==
    // @name         b 站屏蔽黑悟空相关推荐
    // @namespace    http://tampermonkey.net/
    // @version      2024-08-23
    // @description  try to take over the world!
    // @author       h3l
    // @match        https://www.bilibili.com/
    // @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
    // @grant        none
    // ==/UserScript==
    
    (function() {
       'use strict';
    
       // 关键字列表,使用 base64 保存,看到了也不会被剧透
       const encryptedKeywords = ["6buR56We6K+d", "5a2Z5oKf56m6", "57qi5a2p5YS/", "6JmO5YWI6ZSL", "6KW/5ri46K6w", "6buR5oKf56m6", "6buR54y0"];
    
       // 创建一个新数组,用于存储解码后的字符串
       const keywords = encryptedKeywords.map(encodedString => decodeURIComponent(escape(atob(encodedString))));
    
       function removeMatchedCards() {
           // 获取所有的 feed-card 与 bili-video-card 元素
           const cards = document.querySelectorAll('.feed-card, .bili-video-card');
    
           cards.forEach(card => {
               const authorElement = card.querySelector('.bili-video-card__info--author');
               const titleElement = card.querySelector('.bili-video-card__info--tit');
    
               // 检查作者名和标题是否存在
               if (authorElement && titleElement) {
                   const authorName = authorElement.textContent.trim();
                   const titleText = titleElement.textContent.trim();
    
                   // 检查是否命中关键字
                   const isKeywordHit = keywords.some(keyword =>
                                                      authorName.includes(keyword) || titleText.includes(keyword)
                                                     );
    
                   // 如果命中关键字,删除该 feed-card 元素
                   if (isKeywordHit) {
                       console.log(titleText, "removed")
                       card.hidden = true
                   }
               }
           });
       }
    
       // 初始调用,删除已存在的匹配元素
       removeMatchedCards();
    
       // 使用 MutationObserver 监控页面的变化
       const observer = new MutationObserver((mutations) => {
           mutations.forEach((mutation) => {
               // 当页面发生变化时,重新检查并删除匹配的卡片
               removeMatchedCards();
           });
       });
    
       // 监控页面的主体部分(可以根据具体情况调整选择器)
       observer.observe(document.body, { childList: true, subtree: true });
    
    })();
    

    效果如下:

    5 条回复    2024-08-24 17:55:34 +08:00
    Takashi123
        1
    Takashi123  
       49 天前   ❤️ 2
    好奇解码了一下 base64 ,被剧透了。。。。感谢 op 这就安装上。
    68467897
        2
    68467897  
       49 天前   ❤️ 3
    @Takashi123 #1 像是放炮的时候跑过去看炮为什么不响
    610915518
        3
    610915518  
       49 天前
    我也很烦剧透,被迫这两天狂推游戏进度。。。然后手机卸载了 B 站
    SimonOne
        4
    SimonOne  
       49 天前
    再加一个 6buR6ams5Za9
    xidianlz
        5
    xidianlz  
    OP
       48 天前 via iPhone
    @Takashi123 hhhhh 我就是防止被我这个剧透,所以 base64 了下。
    @610915518 手机确实没办法,我直接进关注,然后把剧透的 up 主取关了。
    @SimonOne 感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1016 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 22:23 · PVG 06:23 · LAX 15:23 · JFK 18:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.