// ==UserScript== // @name Bilibili Live Danmaku Filter // @namespace http://tampermonkey.net/ // @version 0.3 // @description 使用一个简单的定时器把弹幕按照给定的正则表达式过滤一遍,征求更好的实现方式中 // @supportURL http://nga.178.com/read.php?tid=17690584 // @author yuyuyzl // @require https://code.jquery.com/jquery-3.4.0.min.js // @require https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js // @grant unsafeWindow // @grant GM_getValue // @grant GM_setValue // @grant GM_setClipboard // @grant GM_info // @match *://live.bilibili.com/* // @downloadURL none // ==/UserScript== var BLDFRegex="【.*"; var BLDFReg; var BLDFNeedSubBody; var BLDFAutoStart; var BLDFShowFilteredDanmaku; var BLDFShowOtherDanmaku; var BLDFIntervalDelay; var intervalID=-1; (function() { 'use strict'; setTimeout(function(){ if((BLDFRegex=GM_getValue("BLDFRegex"))==null)BLDFRegex="【.*】"; if((BLDFNeedSubBody=GM_getValue("BLDFNeedSubBody"))==null)BLDFNeedSubBody=true; GM_setValue("BLDFNeedSubBody",BLDFNeedSubBody); if((BLDFShowFilteredDanmaku=GM_getValue("BLDFShowFilteredDanmaku"))==null)BLDFShowFilteredDanmaku=true; GM_setValue("BLDFShowFilteredDanmaku",BLDFShowFilteredDanmaku); if((BLDFShowOtherDanmaku=GM_getValue("BLDFShowOtherDanmaku"))==null)BLDFShowOtherDanmaku=false; GM_setValue("BLDFShowOtherDanmaku",BLDFShowOtherDanmaku); if((BLDFAutoStart=GM_getValue("BLDFAutoStart"))==null)BLDFAutoStart=false; GM_setValue("BLDFAutoStart",BLDFAutoStart); if((BLDFIntervalDelay=GM_getValue("BLDFIntervalDelay"))==null)BLDFIntervalDelay=20; GM_setValue("BLDFIntervalDelay",BLDFIntervalDelay); // 以下CSS以及字幕框元素来自SOW社团的自动字幕组件 // 发布帖链接:http://nga.178.com/read.php?tid=17180967 $("head").append(''); $(".icon-left-part").append(''); if(BLDFNeedSubBody){ $("#gift-control-vm").before('
"+matchres+"
"); $('.SubtitleTextBody').each(function(i,obj){ $(obj).children().each(function(i,obj){ if(i>=6){ obj.remove(); } }); }); if(BLDFShowFilteredDanmaku)obj.innerText=matchres+' ';else obj.innerText=obj.innerText+' '; }else {if(!BLDFShowOtherDanmaku)$(obj).addClass("invisibleDanmaku");} } })},BLDFIntervalDelay); } if(BLDFAutoStart)startInterval(); $("#regexSettings").click(function(){ BLDFRegex=prompt("输入白名单正则表达式,留空则关闭过滤",BLDFRegex); if(BLDFRegex==null)return; if(intervalID>=0)clearInterval(intervalID); BLDFReg=new RegExp(BLDFRegex); if(BLDFRegex!=""){ startInterval(); GM_setValue("BLDFRegex",BLDFRegex); } }); },3000); })();