BiliBili哔哩哔哩推荐关键词屏蔽

BiliBili哔哩哔哩屏蔽与相应关键词有关的视频与直播

目前為 2020-06-10 提交的版本,檢視 最新版本

// ==UserScript==
// @name BiliBili哔哩哔哩推荐关键词屏蔽
// @description BiliBili哔哩哔哩屏蔽与相应关键词有关的视频与直播
// @namespace https://space.bilibili.com/482343
// @author 超神越鬼
// @license 超神越鬼
// @version 3.0
// @include *t.bilibili.com*
// @include *www.bilibili.com*
// @include *live.bilibili.com*
// @include *space.bilibili.com*
// @exclude *message.bilibili.com*
// @run-at document-end
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
//dd 都屏蔽, bt 只屏蔽标题, zz 只屏蔽up主  在这里添加,运行一次后会保存,在存储里修改删除。 ("","","","","");
var dd = new Array("","","","","");
var bt = new Array("","","","","");
var zz = new Array("","","","","");
var i,c,fl,fk,x,a,b,mo =0,debugx = 1;
var toObj = function( arr ){ var obj = {}; for(var temp in arr){ obj[arr[temp]] = true; } return obj;};
var toArr = function( obj ){ var arr = []; for(var temp in obj){ arr.push(temp); } return arr;};
var together = function( a,b ){ for(var temp=0;temp<b.length;temp++)if(b[temp]!=null && b[temp]!="" && b[temp]!="null" && b[temp].length<40){ a.push(b[temp]); }};
var getUniq = function(arr){ return toArr( toObj(arr) );};
var ddx = GM_getValue("dd",new Array(""));
var btx = GM_getValue("bt",new Array(""));
var zzx = GM_getValue("zz",new Array(""));
together(ddx,dd);together(btx,bt);together(zzx,zz);
ddx =getUniq(ddx);btx =getUniq(btx);zzx =getUniq(zzx);
dd = new Array(); bt = new Array(); zz = new Array();
together(dd,ddx);together(bt,btx);together(zz,zzx);
GM_setValue("dd", dd);GM_setValue("bt", bt);GM_setValue("zz", zz);
bt.push.apply(bt,dd);
zz.push.apply(zz,dd);
function sc() {
     for (x=0;x<zz.length;x++) {
          if(zz[x] != ""){
               if (mo == 1){ //主页
                    fl = document.evaluate('//div[@class="live-card"]/a/div[@class="up"]/div[@class="txt"]/p[@class="name" and contains(text(),"' + zz[x] + '")]/../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("主页作者 1 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
                    fl = document.evaluate('//div[@class="zone-list-box storey-box"]/div[@class="video-card-common"]/a[@class="up" and contains(text(),"' + zz[x] + '")]/..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("主页作者 2 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               if (mo == 3){ //视频
                    fl = document.evaluate('//div[@class="rec-list"]/div[@class="video-page-card"]/div[@class="card-box"]/div[@class="info"]/div[@class="count up"]/a[contains(text(),"' + zz[x] + '")]/../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("视频作者 1 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               if (mo == 6){ //直播
                    fl = document.evaluate('//div[@class="room-ctnr w-100"]/div[@class="room-card-wrapper p-relative dp-i-block"]/a/div[@class="card-info-ctnr"]/div[@class="text-info-ctnr body-bg p-relative dp-i-block v-middle"]/div[@class="room-anchor card-text p-relative"]/span[contains(text(),"' + zz[x] + '")]/../../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("直播作者 1 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               if (mo == 7){ //在线列表up主
                    fl = document.evaluate('//div[@class="online-list"]/div[@class="ebox"]/div[@class="dlo"]/a[contains(text(),"' + zz[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("在线作者 1 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               fl = document.evaluate('//div[@class="zone-list-box"]/div[@class="video-card-common"]/a[@class="up"]/i[contains(text(),"' + zz[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("作者1 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//div[@class="ext-box"]/div[@class="video-card-common ex-card-common"]/a[@class="ex-up"]/i[contains(text(),"' + zz[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("作者2 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//div[@class="ext-box"]/div[@class="video-card-common ex-card-common"]/a[contains(text(),"' + zz[x] + '")]/..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("作者3 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//div[@class="zone-list-box"]/div[@class="article-card"]/div/a[@class="up" and contains(text(),"' + zz[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("作者4 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//*[@id="reportFirst1"]/div[2]/div/div[1]/a/div/p[@class="up"  and contains(text(),"' + zz[x] + '")]/../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("作者5 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//div[@class="groom-box-m clearfix"]/div[@class="groom-module"]/a/div[@class="card-mark"]/p[@class="author"  and contains(text(),"' + zz[x] + '")]/../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("作者6 ",zz[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
          }}
     for (x=0;x<bt.length;x++) {
          if(bt[x] != ""){
               if (mo == 1){ //主页
                    fl = document.evaluate('//div[@class="live-card"]/a/div[@class="up"]/div[@class="txt"]/p[@class="desc" and contains(text(),"' + bt[x] + '")]/../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("主页 标题 1 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }

                    fl = document.evaluate('//div[@class="zone-list-box"]/div[@class="video-card-common"]/a[@class="title" and contains(text(),"' + bt[x] + '")]/..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("主页 标题 2 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
                    fl = document.evaluate('//div[@class="zone-list-box storey-box"]/div[@class="video-card-common"]/a[@class="title" and contains(text(),"' + bt[x] + '")]/..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("主页 标题 3 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
                    fl = document.evaluate('//div[@class="zone-list-box"]/div[@class="article-card"]/div/a[@class="title" and contains(text(),"' + bt[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("主页 标题 4 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
                    fl = document.querySelectorAll("#ranking-all > div > ul.rank-list.hot-list > li > a")
                    for (i = fl.length-1; i>-1 ; i--) {
                         if (fl[i].innerText.indexOf(bt[x])>-1){
                              if (debugx)console.log("主页 标题 5 ",bt[x]," : ", fl[i].innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl[i].parentElement);
                              fl[i].parentElement.remove();
                         }
                    }
                    fl = document.querySelectorAll("div.rank-list > div > a > p")
                    for (i = fl.length-1; i>-1 ; i--) {
                         if (fl[i].innerText.indexOf(bt[x])>-1){
                              if (debugx)console.log("主页 标题 6 ",bt[x]," : ", fl[i].innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl[i].parentElement.parentElement);
                              fl[i].parentElement.parentElement.remove();
                         }
                    }
               }
               if (mo == 2){ //频道
                    fl = document.evaluate('//div[@class="storey-box clearfix"]/div[@class="spread-module"]/a/p[@class="t" and contains(text(),"' + bt[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("频道标题 2  ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
                    fl = document.querySelectorAll("div.rank-list-wrap > ul > li")
                    for (i = fl.length-1; i>-1 ; i--) {
                         if (fl[i].innerText.indexOf(bt[x])>-1){
                              if (debugx)console.log("频道标题 3 ",bt[x]," : ", fl[i].innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl[i]);
                              fl[i].remove();
                         }
                    }
                    fl = document.evaluate('//div[@class="groom-box-m clearfix"]/div[@class="groom-module"]/a/div[@class="card-mark"]/p[@class="title"  and contains(text(),"' + bt[x] + '")]/../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("频道标题 4 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               if (mo == 3){ //视频
                    fl = document.evaluate('//div[@class="rec-list"]/div[@class="video-page-card"]/div[@class="card-box"]/div[@class="info"]/a[@class="title" and contains(text(),"' + bt[x] + '")]/../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("视频标题 1 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               if (mo == 5){//动态
                    fl = document.querySelectorAll("#app > div > div.container > div > div > div > div > div.center-box > a");
                    for (i = fl.length-1; i>-1 ; i--) {
                         if (fl[i].innerText.indexOf(bt[x])>-1){
                              if (debugx)console.log("动态标题 ",bt[x]," : ", fl[i].innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl[i].parentElement.parentElement.parentElement);
                              fl[i].parentElement.parentElement.parentElement.remove();
                         }
                    }
               }
               if (mo == 6){ //直播
                    fl = document.evaluate('//div[@class="room-ctnr w-100"]/div[@class="room-card-wrapper p-relative dp-i-block"]/a/div[@class="card-info-ctnr"]/div[@class="text-info-ctnr body-bg p-relative dp-i-block v-middle"]/span[contains(text(),"' + bt[x] + '")]/../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("直播标题 1 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               if (mo == 7){ //在线列表标题
                    fl = document.evaluate('//div[@class="online-list"]/div[@class="ebox"]/a[1]/p[contains(text(),"' + bt[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                    if (fl.snapshotLength) {
                         for (i = fl.snapshotLength-1; i>-1 ; i--) {
                              if (debugx)console.log("在线标题 1 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                              fl.snapshotItem(i).remove();
                         }
                    }
               }
               //视频标题
               fl = document.evaluate('//div[@class="ext-box"]/div[@class="video-card-common"]/a[@class="title" and contains(text(),"' + bt[x] + '")]/..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("标题1 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//div[@class="ext-box"]/div[@class="video-card-common"]/a[@class="title"]/span[contains(text(),"' + bt[x] + '")]/../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("标题2 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//div[@class="ext-box"]/div[@class="video-card-common ex-card-common"]/div/a/p[contains(text(),"' + bt[x] + '")]/../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("标题3 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }
               fl = document.evaluate('//*[@id="reportFirst1"]/div[2]/div/div[1]/a/div/p[1 and contains(text(),"' + bt[x] + '")]/../../../..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
               if (fl.snapshotLength) {
                    for (i = fl.snapshotLength-1; i>-1 ; i--) {
                         if (debugx)console.log("标题4 ",bt[x]," : ", fl.snapshotItem(i).innerText.replace(/\n/g," ").replace(/\s\s/g," "),'\n            ',fl.snapshotItem(i));
                         fl.snapshotItem(i).remove();
                    }
               }

          }
     }
     if (mo == 4){ //个人页面
          fl = document.querySelectorAll("#submit-video-list > ul.clearfix.cube-list > li > a.title");
          if (fl.length>0) {
               for (i = 0; i < fl.length; i++) {
                    a=0;
                    for (x in bt) {
                         if(bt[x] != ""){
                              if(fl[i].innerText.indexOf(bt[x])>-1){
                                   a=1; break;
                              }
                         }
                    }
                    if (fl[i].parentElement.style.display!="none" && a==1){
                         if (debugx)console.log("个人标题 隐藏 1 ",bt[x]," :",fl[i].innerText);
                         fl[i].parentElement.style.display="none";
                    }
               }
          }
     }
     //频道推荐
     if (mo == 2){
          fl = document.querySelectorAll("div.video-card-box > div > div > a > p.title");
          fk = document.querySelectorAll("div.video-card-box > div > div > a > p:nth-child(5) > span");
          if (fl.length>0) {
               for (i = 0; i < fl.length; i++) {
                    a=0;
                    for (x in bt) {
                         if(bt[x] != ""){
                              if(fl[i].innerText.indexOf(bt[x])>-1){
                                   a=1; break;
                              }
                         }
                    }
                    if (fl[i].parentElement.style.display!="none" && a==1){
                         if (debugx)console.log("频道标题 1 隐藏 ",bt[x]," :",fl[i].innerText);
                         fl[i].parentElement.style.display="none";
                         continue;
                    }
                    if (a==0){
                         fk = fl[i].parentElement.querySelector('p:nth-child(5) > span').innerText;
                         for (x in zz) {
                              if(zz[x] != ""){
                                   if(fk.indexOf(zz[x])>-1){
                                        a=1; break;
                                   }
                              }
                         }
                    }
                    if (fl[i].parentElement.style.display!="none" && a==1){
                         if (debugx)console.log("频道作者 1 隐藏 ",zz[x]," :",fk);
                         fl[i].parentElement.style.display="none";
                         continue;
                    }
                    if (fl[i].parentElement.style.display=="none" && a==0){
                         if (debugx)console.log("频道推荐 1 显示    :",fl[i].innerText,"    ",fk);
                         fl[i].parentElement.style.display="block";
                    }
               }
          }
     }
     return false;
}
var wz=location.href;
var kj=3000;
if ((wz.indexOf("live.bilibili.com")>-1 && wz.split(".com/")[1].length>0)){return}
//mo 模式 1主页 2频道 3视频 4个人页面 5动态 6直播 7在线
var mode=['','主页','频道','视频','个人页面','动态','直播','在线'];
if (wz.split("bilibili.com")[1].length<2){ kj=5000; mo=1;}
if (wz.indexOf("/v/")>-1 || wz.indexOf("guochuang/")>-1){kj=3000; mo=2;}
if ((wz.indexOf("video/")>-1&& wz.indexOf("online.html")<0) || wz.indexOf("play/")>-1){ kj = 10000; mo = 3;}
if (wz.indexOf("space.bilibili.com")>-1){ kj=3000; mo=4;}
if (wz.indexOf("t.bilibili.com")>-1){ kj=3000; mo=5;}
if (wz.indexOf("live.bilibili.com")>-1){kj=15000; mo=6;}
if (wz.indexOf("online.html")>-1){kj=15000; mo=7;}
if (mo ==0)return;
if (mo == 3){
     if (debugx)console.log("模式 ",mo,' ',mode[mo],' ',kj,'   ',location.href);
     setTimeout(sc,kj);
}else{
     if (debugx)console.log("模式 ",mo,' ',mode[mo],' ',kj,'   ',location.href);
     setTimeout(sc,1500);
     setInterval(sc,kj);
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址