├── README.md └── pakku-advanced-filter.user.js /README.md: -------------------------------------------------------------------------------- 1 | # B站弹幕屏蔽Pro+ 2 | 3 | [greasyfork](https://greasyfork.org/zh-CN/scripts/42635-pakku-advanced-filter) 4 | 5 | 依赖于 [pakku ≥ v10.0](https://github.com/xmcp/pakku.js) 6 | 7 | *License: WTFPL* 8 | 9 | -------------------------------------------------------------------------------- /pakku-advanced-filter.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name pakku advanced filter 3 | // @namespace http://s.xmcp.ml/pakkujs/ 4 | // @version 0.3 5 | // @description 弹幕屏蔽Pro+ 6 | // @author xmcp 7 | // @match *://*.bilibili.com/* 8 | // @grant none 9 | // ==/UserScript== 10 | 11 | // 请先安装 [pakku](http://s.xmcp.ml/pakkujs/) 12 | 13 | const NEED_UID = true; // 是否需要使用 cracked_uid 属性(慢) 14 | 15 | // 屏蔽规则写在这个函数里 16 | function do_filter(D) { 17 | var ret = []; 18 | D.forEach((d) => { 19 | ret.push(d.ir_obj); 20 | }); 21 | return ret; 22 | } 23 | 24 | (function() { 25 | 'use strict'; 26 | 27 | function comp_ver(ver1, ver2) { 28 | ver1 = ver1.split('.').map( s => s.padStart(10) ).join('.'); 29 | ver2 = ver2.split('.').map( s => s.padStart(10) ).join('.'); 30 | return ver1 < ver2; 31 | } 32 | function check_ver(ver) { 33 | if(comp_ver(ver, '10.0')) 34 | alert('此版本的 pakku advanced filter 用户脚本依赖于 pakku 10.0 或更高版本'); 35 | } 36 | 37 | let COMPLETED_TIME=-10000; 38 | 39 | addEventListener('message', function(e) { 40 | if(e.data.type==='pakku_event_danmaku_loaded') { 41 | if((+new Date())-COMPLETED_TIME<5000) return; 42 | check_ver(e.data.pakku_version||'0'); 43 | if(NEED_UID) { 44 | postMessage({type: 'pakku_get_danmaku_with_uid'},'*'); 45 | } else { 46 | postMessage({type: 'pakku_get_danmaku'},'*'); 47 | } 48 | } else if(e.data.type==='pakku_got_danmaku') { 49 | const D=do_filter(e.data.resp); 50 | console.log('pakku advanced filter: '+D.length+' danmakus left'); 51 | COMPLETED_TIME=(+new Date()); 52 | window.postMessage({type: 'pakku_set_danmaku_bounce', danmakus: D},'*'); 53 | } 54 | }); 55 | })(); --------------------------------------------------------------------------------