Bilibili UP blocker

Customizable Bilibili UP blocker via UID -- 利用 UID 屏蔽 b站 UP主

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Bilibili UP blocker
// @namespace    https://github.com/sync-coding
// @version      1.1
// @description  Customizable Bilibili UP blocker via UID -- 利用 UID 屏蔽 b站 UP主
// @author       sync-coding
// @license      GNU GPLv3
// @match        *.bilibili.com/*
// @grant        GM_log
// @run-at       document-end
// @charset      UTF-8
// ==/UserScript==


'use strict';

var localBlockList = [];
var remoteBlockList = [];
var blockList = localBlockList.concat(remoteBlockList);

setInterval(function(){

    var allVideoOwnerElements, videoOwnerElement;
    allVideoOwnerElements = document.evaluate(
        '//a[@class="bili-video-card__info--owner"]',
        document,
        null,
        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
        null);
    var i;
    for (i = 0; i < allVideoOwnerElements.snapshotLength; i++) {
        var node = allVideoOwnerElements.snapshotItem(i);
        var href = node.attributes.getNamedItem("href").value;
        if (href.match(/\/\/space.bilibili.com\/.*/g))
        {
            var UID = parseInt(href.replace(/.*com\//i,""));
            if (blockList.includes(UID))
            {
                node.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
            }
        }
   }

},1000);