🏠 Home 

B站通过黑名单屏蔽UP主视频和评论

获取B站黑名单,过滤对应UP主的视频及评论(视频:首页、搜索页、视频右侧推荐栏)

// ==UserScript==
// @name         B站通过黑名单屏蔽UP主视频和评论
// @namespace    https://greasyfork.org/zh-CN/users/810690-twinsdestiny
// @version      0.5
// @description  获取B站黑名单,过滤对应UP主的视频及评论(视频:首页、搜索页、视频右侧推荐栏)
// @author       TwinsDestiny
// @match        *://*.bilibili.com/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/minified/arrive.min.js
// @require      https://code.jquery.com/jquery-2.2.4.min.js
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==
(async function () {
'use strict';
let blockList = new Array();
// 获取当前页面的 Cookie
const cookies = document.cookie;
// 隐藏
await document.arrive('body', { fireOnAttributesModification: false, onceOnly: false, existing: true }, async function () {
var myHeaders = new Headers();
myHeaders.append("Cookie", cookies);
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow',
credentials: "include"
};
fetch("https://api.bilibili.com/x/relation/blacks?jsonp=jsonp&pn=1&ps=20&re_version=0", requestOptions)
.then(response => response.json())
.then((r###lt) => {
let total = r###lt.data.total;
let pages = Math.floor(total/20)+1;
for(let i = 1;i<=pages;i++){
fetch("https://api.bilibili.com/x/relation/blacks?jsonp=jsonp&pn="+i+"&ps=20&re_version=0", requestOptions)
.then(response => response.json())
.then((r###lt) => {
r###lt.data.list.forEach((data) => {
blockList.push(data.uname);
});
})
.catch(error => console.log('error', error));
}
})
.catch(error => console.log('error', error));
setInterval(function () {
$(".bili-video-card").each(function () {
var authorSpan = $(this).find(".bili-video-card__info--author");
if (authorSpan.length > 0) {
var authorName = authorSpan.text().trim();
if ($.inArray(authorName, blockList) !== -1) {
//$(this).parent().remove();
$(this).remove();
}
}
});
$(".video-page-card-small").each(function () {
var authorSpan = $(this).find(".name");
if (authorSpan.length > 0) {
var authorName = authorSpan.text().trim();
if ($.inArray(authorName, blockList) !== -1) {
//$(this).parent().remove();
$(this).remove();
}
}
});
$(".user-list").each(function () {
var authorSpan = $(this).find(".user-name");
if (authorSpan.length > 0) {
var authorName = authorSpan.text().trim();
if ($.inArray(authorName, blockList) !== -1) {
//$(this).parent().remove();
$(this).remove();
}
}
});
$(".sub-reply-item").each(function () {
var authorSpan = $(this).find(".sub-user-name");
if (authorSpan.length > 0) {
var authorName = authorSpan.text().trim();
if ($.inArray(authorName, blockList) !== -1) {
//$(this).parent().remove();
$(this).remove();
}
}
});
$(".root-reply-container").each(function () {
var authorSpan = $(this).find(".user-name");
if (authorSpan.length > 0) {
var authorName = authorSpan.text().trim();
if ($.inArray(authorName, blockList) !== -1) {
//$(this).parent().remove();
$(this).remove();
}
}
});
}, 500);
});
})();