Add bilibili-block-up.js

This commit is contained in:
Newnius 2025-01-23 13:03:42 +00:00
parent 2bbb432f53
commit 5096538862

110
bilibili-block-up.js Normal file
View File

@ -0,0 +1,110 @@
// ==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
// @downloadURL https://update.greasyfork.org/scripts/437587/Bilibili%20UP%20blocker.user.js
// @updateURL https://update.greasyfork.org/scripts/437587/Bilibili%20UP%20blocker.meta.js
// ==/UserScript==
'use strict';
var localBlockList = [];
var remoteBlockList = [202660651, 1602538418, 2376291, 22593014, 1039973059, 390969643, 487614876, 432791764, 404194769, 1525349618, 13231881, 1178974961, 1623427575, 3461565093251147, 1040421406, 29385547, 407275913, 1180987422,
3493092682369229, 3537109751172002, 3546639595736039, 3493121602096085, 1768331887, 3494372689578773, 2117439536, 3493114863946205, 282406197, 566726502, 3493262503446724, 2131335665, 1805751605, 1557073149,
40484108, 472722692, 95237999, 3493117328100101, 46470268, 351515511, 3546612324371022, 1131457022, 524491970, 3546630468929938, 3493107370822154, 10330740, 673798320, 253285294, 2059379932, 515155585,
517433879, 669981885, 1796644024, 675525852, 525382468, 387087511, 1714867793, 556890036, 1970074409, 3493144712710647, 395991094, 3537104715909319, 390483777, 1389004086, 3546668244929295, 316955009,
3461565793700786, 1604162142, 604710494, 394848799, 687664429, 270355850, 1359649319, 488022370, 20857305, 153525294, 1809115404, 10119428, 508959410, 29296192, 164119526, 488055582, 284850562,
12394995, 3461563876903505, 3494366354082721, 289189019, 607563758, 3493109673495098, 288603520, 418503039, 3546583454976272, 386186788, 3537123319744983, 456664753, 673810839, 481237760, 3546602411133561,
91281561, 3537124867443480, 274298404, 942755, 10334523, 264476476, 7380321, 170059, 1068406559, 253350665, 478879330, 77075859, 483130324, 414376802, 1119253352, 413276548, 1761495227, 946974,
523084772, 3537122973714533, 1895305615, 1724234889, 502168608, 1895648674, 381339027, 11482657, 235059935, 323859250, 1147735679, 1182633851, 1291137530, 20131205, 668137962, 386923748, 1988066131,
1348623617, 14333871, 3546653262874784, 2135949274, 1551364363, 481035170, 1527828440, 31012715, 639981785, 35218300, 392983644, 14006709, 43954358, 3546642210883870, 1805727286, 493408382, 7969579,
676755409, 472733310, 1218476567, 473560185, 1767282898, 402116397, 1121622047, 592878184, 1923960836, 593801873, 583697223, 590571924, 3493143743826024, 1737252623, 149558293, 3493280870304704,
436230335, 145750219, 320627478, 3494376653195916, 1474080294, 430082207, 447141001, 3493084377647695, 3546583509502560, 330987375, 1569685991, 478398611, 1434168227, 35048695, 1265006074, 399618635,
40965506, 1024607332, 3494360461084962, 413604662, 2053091487, 3546380398233946, 185549749, 1340733361, 2020615178, 1749429500, 3461579240638841, 1975692083, 12656725, 490487433, 3546387176229029,
1631053310, 3537109939915595, 2008781516, 1261064092, 697295293, 1518087943, 1850760633, 3493258317531658, 477430762, 3494372452600241, 3546622413768823, 504986874, 3493091570879291, 450935543, 843798,
1939744250, 574027575, 494713149, 617085602, 701504703, 153890218, 1126765688, 17856206, 32642294, 3546574894401869, 508759659, 17856206, 3546574894401869, 390267236, 2102913210, 3493105439345124,
1502795824, 430739570, 330908102, 1336523353, 3461577432894072, 3546657035651838, 3493282747255341, 271179660, 586658611, 594840903, 1573719674, 1917973342, 3537116745173433, 673835935, 3494352783411283,
384976998, 174832680, 115153318, 3493109503625730, 227830959, 28973428, 3493079036201727, 3546559471945807, 2024417215, 3303524, 227830959, 3546610772478508, 283659872, 5294454, 263131288, 1823613731,
1424768125, 3546556852603448, 3546583079586784, 3546652507900050, 250701455, 518384286, 1167890778, 1980721893, 3546675075352996, 362006943, 29147005, 3493094345411213, 525831153, 15133657, 2119493297,
1788734204, 441323326, 485385245, 3546621725903648, 3546673320036989, 1753768110, 1496160939, 24470293, 1630625, 690149633, 3546620310326128, 140173296, 3546669087984209, 383691275, 3546702384466408,
3546671403240273, 1024566330, 691830785, 689239105, 640314628, 160380250, 3546571153082836, 3493258596453327, 552642893, 398123845, 3546597243750554, 66089290, 102850283, 371722854, 12981887,
2024368375, 480784649, 3546638165478259, 488994420, 1951485267, 3493270688631313, 34901935, 545965197, 430201588, 1993622908, 438842639, 5087326, 3537120815745590, 432597324, 3546668456741177,
201661640, 3546692907436162, 502402166, 3546721418218388, 3493086898424743, 52917187, 1164943772, 3546669677283820, 3546581265550301, 3546630431181174, 3546568544225856, 3546579665423077, 3613905,
1114812116, 52226303, 3493115352582215, 3461583202158638, 3537116785018967, 251317078, 10272440, 3461564921284715, 3546728894564951, 346563107, 317992583, 32012149, 3493142779136612, 3546672554576045,
95138179, 267956107, 3546706253711896, 3546740108036790, 3546376306690507, 1068501708, 604100865, 353896033, 516316998, 703186600, 472149476, 110930331, 374377163, 421199310, 1117551831, 25471752,
1765958368, 3546768050489957, 57540159, 408392628, 3546727604816030, 448165099, 3546634591931021, 1256623768, 1384496294, 24087479, 62650351, 321595646, 61086273, 1578081013, 100987521, 3546635506288886,
397685003, 357912720, 6011515, 11979637, 3546712538876281, 3546640828860467, 3546649248926059, 3546656245025479, 3546601995897610, 1219356839, 3546697722497616, 522836052, 357655347, 435931665,
3461577434990932, 3493104101362182, 3494354765220379, 1390820702, 13322950, 1137810332, 673357150, 388231140, 1800770427, 3546394388335189, 3546801655253024, 1093906861, 26059848, 397286677,
94281836, 3546669830376273, 1074812545, 440751588, 3546784219532246, 483053920, 3546703567260242, 38650338, 1908413665, 3493258531440857, 1722898101, 49454741, 10518076, 3546803366529645,
502904220, 3537109568719060, 3537124464789799, 552405415, 1311050968, 700574767, 2342793, 3546567885720395, 265997439, 384350846, 357793425, 174795249, 1930307356, 1655372955, 3493261140298454,
39392104, 1780857798, 1118427177, 3493138024893095, 285571498, 1754774912, 697657606, 392218999, 1344314546, 1819569191, 1143579994, 111578972, 3546391118874713, 3546688367102580, 574138012,
3546576079293273, 21412328, 472502549, 78176056, 606626588, 2115484831, 3546606469123022, 147728557, 3546686483859581, 3493134161938695, 3546770701290061, 1722786822, 3546651841006323,
1624089480, 416609327, 3546587026426766, 1703465813, 2025190588, 383557147, 3546802567514846, 3493295594408697, 414035684, 2003541499, 3546800384379371, 328359509, 483679925, 3546617680497490,
1342657662, 3493087504500974, 3546587456342714, 39335300, 12210964, 23981597, 3546736815508298, 3546686483859581, 1546325367, 3493289336506403, 1743617724, 1872863919, 1942399375, 3546816505187182,
406899358, 588912831, 90961940, 1105602743, 281573080, 196059618, 696369491, 3546573407521112, 498115986, 3546789305124955, 3494374566529408, 676927723, 3537110556477457, 513320674, 66567036,
2105728384, 92459952, 3537118223666103, 637105846, 97268123, 1347355221, 518438886, 3546695277218752, 1874572528, 1729766282, 3546815488068149, 1974450273, 3546698815114028, 3546377864874467,
3546602421619009, 668514458, 420323022, 504157415, 3494377980692895, 513413104, 49664588, 675956030, 1206069909, 3546603883334003, 3546812705147650, 1109741373, 90445151, 286398266, 1528427197
];
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();
}
} else if (href.match(/\/\/cm.bilibili.com\/.*/g))
{
// console.log(ad_href);
// console.log("match");
node.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
}
}
var allAdElements;
allAdElements = document.evaluate(
'//a[@class="bili-video-card__info--owner disable-hover"]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for (i = 0; i < allAdElements.snapshotLength; i++) {
var ad_node = allAdElements.snapshotItem(i);
var ad_href = ad_node.attributes.getNamedItem("href").value;
if (ad_href.match(/\/\/cm.bilibili.com\/.*/g))
{
// console.log(ad_href);
// console.log("match");
ad_node.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
} else {
console.log(ad_href);
}
}
},1000);