// ==UserScript== // @name BiliBili Tags Blocker BiliBili标签屏蔽助手 // @namespace https://greasyfork.org/zh-CN/users/924205-xiao-xi // @version 0.8.0 // @description 眼不见为净,耳不听为清,心不想则静 // @author xiaoxi // @license MIT // @include *://www.bilibili.com/* // @include *://t.bilibili.com/* // @include *://search.bilibili.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com // @require https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js // @require https://unpkg.com/ajax-hook@2.1.3/dist/ajaxhook.min.js // @require https://cdn.jsdelivr.net/npm/arrive@2.4.1/minified/arrive.min.js // @require https://greasyfork.org/scripts/407543-block-obj/code/Block_Obj.js?version=963893 // @grant GM_xmlhttpRequest // @grant unsafeWindow // @grant GM_getValue // @grant GM.getValue // @grant GM_setValue // @grant GM.setValue // @grant GM_setClipboard // @grant GM.setClipboard // @grant GM_registerMenuCommand // @grant GM_addValueChangeListener // @run-at document-start // @downloadURL none // ==/UserScript== // https://greasyfork.org/zh-CN/scripts/417760-checkjquery var BiliBiliTagsBlocker = { functionEnable: true, matchTitle: true, onlyChangeColorEnable: false, removeAllAD: false, removeSpecialEnable: false, removeNextVideo: false, homeCover: false, removeSearchTrend: false, removeSearchHistory: false, matchTopic: false, removeRightBanner: false, removeLive: false, removeBottomActivity: false, removeVideoPopupBox: false, removeEndVideo: false, blurMode: false, hiddenMode: false, fuzzyMatch: false, tagsArray: [], titlesArray: [], }; const BASIC_STYLE = ` .block_obj_checkbox_label { padding-left: 13px; } `; let blockObj = new Block_Obj('BiliBili_Tags_Blocker'); document.arrive("body", { fireOnAttributesModification: true, onceOnly: true, existing: true }, function() { initSettingUI() }); function initSettingUI(){ blockObj.init({ id: 'BiliBiliTagsBlocker', menu: 'Tags屏蔽设置', style: BASIC_STYLE, field: [ { id: 'version', label: 'v0.8.0', type: 's', }, { id: 'functionEnable', label: '启用屏蔽功能', title: '总开关', type: 'c', default: true, }, { id: 'onlyChangeColorEnable', label: '看看屏蔽了什么', title: '更改屏蔽视频的背景色', type: 'c', default: false, }, { label: '屏蔽模式', type: 's', }, { id: 'blurMode', label: '模糊模式', type: 'c', default: false, }, { id: 'hiddenMode', label: '隐藏模式', type: 'c', default: false, }, { id: 'fuzzyMatch', label: '模糊匹配', title: '例如视频标签‘原神2.8’会匹配到添加的标签的‘原神’', type: 'c', default: false, }, { id: 'matchTitle', label: '匹配视频标题', title: '。。。', type: 'c', default: true, }, { label: '首页设置', type: 's', }, { id: 'homeCover', label: '首页遮罩(暂时移除)', title: '加载图', type: 'c', default: false, }, { label: '搜索页设置', type: 's', }, { id: 'removeSearchTrend', label: '移除热搜栏', title: '推荐的什么jb', type: 'c', default: false, }, { id: 'removeSearchHistory', label: '匹配并移除历史词条', title: '。。。', type: 'c', default: false, }, { label: '动态页设置', type: 's', }, { id: 'matchTopic', label: '话题栏匹配标题关键字', title: '都是些什么jb', type: 'c', default: false, }, { label: '视频页设置', type: 's', }, { id: 'removeNextVideo', label: '移除接下来播放', title: '推荐的什么jb', type: 'c', default: false, }, { id: 'removeEndVideo', label: '移除结束后视频', title: '推荐的什么jb', type: 'c', default: false, }, { id: 'removeAllAD', label: '移除所有推广', title: '。。。', type: 'c', default: false, }, { id: 'removeVideoPopupBox', label: '移除视频内所有消息框', title: '例如关注,三连,投票,投票跳转其他视频', type: 'c', default: false, }, { label: 'Tag设置', type: 's', }, { id: 'tagInput', label: '', placeholder: ' 同时输入多个时以英文逗号分隔 ', type: 'i', list_id: 'tagsArray', }, { id: 'tagsArray', type: 'l', default: [], }, { label: '标题关键字 (例如‘原 神’标题,请输入‘原神’)', type: 's', }, { id: 'titleInput', label: '', placeholder: ' 同时输入多个时以英文逗号分隔 ', type: 'i', list_id: 'titlesArray', }, { id: 'titlesArray', type: 'l', default: [], }, ], events: { save: config => { BiliBiliTagsBlocker = config; }, change: config => { BiliBiliTagsBlocker = config; }, }, }) } //视频信息 var videoInfo = []; let href = location.href; let matchSearch = href.match(/search.bilibili/); let matchPopular = href.match(/popular/); let matchRank = href.match(/\/popular\/rank/); let matchPost = href.match(/t.bilibili/); let matchVideo = href.match(/video/); let matchHome = href.match(/bilibili.com/); //==============视频页================ function initVideoListener(){ var targetNode = $('.rec-list')[0]; var options = {childList: true}; function callback(mutationsList, observer) { if(mutationsList.length >= 1 && mutationsList[0].addedNodes.length!=0){ $.each(mutationsList, function(i, m){ initvideoInfo(m.addedNodes[0]) }); } } let mutationObserver = new MutationObserver(callback); let checkTarget = setInterval(function () { targetNode = $('.rec-list')[0]; if(targetNode != undefined && targetNode != null){ mutationObserver.observe(targetNode, options); clearInterval(checkTarget); if(BiliBiliTagsBlocker.removeAllAD){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ $($(targetNode).children("div")[0]).css({"background":"blue"}); } else { if(BiliBiliTagsBlocker.blurMode){ $($(targetNode).children("div")[0]).css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ $($(targetNode).children("div")[0]).css({"display":"none"}); } } } $.each($(targetNode).children(".video-page-card"), function(i, m){ initvideoInfo(m) }); } }, 50); } function initvideoInfo(card){ let info = $(card).children(".card-box").children(".info").children("a") let href = $(info).attr("href"); let title = $(info).children('span').attr("title"); let videoCard = $(card); let bv = getBvcountber(href) $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(tags.data,function(i,t){ $.each(t,function(i,tag){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ videoCard.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ videoCard.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ videoCard.css({"display":"none"}); } } successed = true } }) }) } else{ $.each(tags.data, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if(tag.tag_name.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ videoCard.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ videoCard.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ videoCard.css({"display":"none"}); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ title = replaceAllSymbol(title) if(title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ videoCard.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ videoCard.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ videoCard.css({"display":"none"}); } } successed = true } }) } }, }); } //接下来播放 function initNextVideoListener(){ $(document).arrive('#reco_list', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ let next = $(this).children('.next-play') if (BiliBiliTagsBlocker.onlyChangeColorEnable) { next.css({"background":"blue"}) } else { next.css({"display":"none"}) } }) } //结束视频 function removeEndVideo(){ $(document).arrive('.bpx-player-ending-related', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).remove(); $('.bpx-player-ending-functions').animate({ marginTop: 145, opacity: 'show' }, "slow"); }) } //右下角推广 function removeRightBanner(){ $(document).arrive('#right-bottom-banner', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).css({"display":"none"}) }) } //右下角直播 function removeLive(){ $(document).arrive('#live_recommand_report', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).css({"display":"none"}) }) } //视频下方活动 function removeBottomActivity(){ $(document).arrive('#activity_vote', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).css({"display":"none"}) }) } //推广视频 function removeAdVideo(){ $(document).arrive('.video-ad-creative-card', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).css({"display":"none"}) }) } //视频内消息框 function removeVideoPopupBox(){ $(document).arrive('.bpx-player-popup', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ $(this).remove(); }) $(document).arrive('.bpx-player-follow', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ $(this).remove(); }) //三连 $(document).arrive('.bpx-player-popup-guide-all', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ $(this).remove(); }) //投票 $(document).arrive('.bpx-player-popup-vote', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ $(this).remove(); }) //跳转其他视频 $(document).arrive('.bpx-player-link', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ $(this).remove(); }) } //活动通知 $(document).arrive('.reply-notice', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ $(this).css({"display":"none"}) }) //=======================热门页面========================= function initPopularVideoInfo(url){ videoInfo = [] let l1 = url.indexOf('pn='); let num = url.substring(l1+3,url.length) let checkTarget = setInterval(function () { let videoCardList = $(".video-card__content"); if(videoCardList != null && videoCardList != undefined){ if(num != 1){ if(BiliBiliTagsBlocker.blurMode){ videoCardList = videoCardList.slice((num-1)*20,videoCardList.length) } } videoCardList.each(function(i){ let href = $(this).children("a").attr("href"); let videoCard = $(this).parent(".video-card"); let title = $($(videoCard).children(".video-card__info")).children("p").attr("title"); title = replaceAllSymbol(title) let bvInfo = { bv : "BV"+getBvcountber(href), card : videoCard, title : title, } videoInfo.push(bvInfo); if(videoInfo.length > 0){ clearInterval(checkTarget); } }); } }, 50); let checkTarget1 = setInterval(function () { if(videoInfo.length > 0 && BiliBiliTagsBlocker.tagsArray != null && BiliBiliTagsBlocker.tagsArray != undefined && BiliBiliTagsBlocker.tagsArray.length >= 1){ $.each(videoInfo, function(i, v){ $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+v.bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(tags.data,function(i,t){ $.each(t,function(i,tag){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) }) } else{ $.each(tags.data, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if(tag.tag_name.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if( v.title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) } }, }); }); clearInterval(checkTarget1); } }, 50); } //=======================排行榜========================= function initRankVideoInfo(){ let videoInfo = []; if(!location.href.match(/\/rank\/bangumi/) || !location.href.match(/\/rank\/guochan/) || !location.href.match(/\/rank\/documentary/) || !location.href.match(/\/rank\/movie/) || !location.href.match(/\/rank\/tv/) || !location.href.match(/\/rank\/variety/)){ let checkTarget = setInterval(function () { let videoCardList = $(".rank-item"); if(videoCardList != null && videoCardList != undefined){ videoCardList.each(function(i){ let info = $(this).children(".content").children(".info").children("a"); let href = $(info).attr("href"); let title = $(info).text(); title = replaceAllSymbol(title) let videoCard = $(this); let bvInfo = { bv : "BV"+getBvcountber(href), card : videoCard, title : title } videoInfo.push(bvInfo); if(videoInfo.length > 99){ clearInterval(checkTarget); } }); } }, 50); let checkTarget1 = setInterval(function () { if(videoInfo.length > 99 && BiliBiliTagsBlocker.tagsArray != null && BiliBiliTagsBlocker.tagsArray != undefined && BiliBiliTagsBlocker.tagsArray.length >= 1){ $.each(videoInfo, function(i, v){ $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+v.bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(tags.data,function(i,t){ $.each(t,function(i,tag){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) }) } else{ $.each(tags.data, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if(tag.tag_name.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(v.title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) } }, }); }); clearInterval(checkTarget1); } }, 50); } } //==================搜索页面======================= var videoInfo2 = [] //推广视频 function removeTrend(){ $(document).arrive('.trending', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).remove() }) } setTimeout(function(){ //搜索页游戏标签 $(document).arrive('.game-item', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).remove() }) //搜索页活动标签 $(document).arrive('.activity-item', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ $(this).remove() }) },800); //手动请求ajax function clickSearchAgain(){ //$('.page-item.active').children('button').click() //console.log($('.page-item.active').children('button')) $('div.search-button').click() } function initSearchVideoInfo(){ let checkTarget = setInterval(function () { if(responses.length >= 1){ let r = [] let checkTarget1 = setInterval(function () { if(r.length > 1 ){ setVideoInfo(r[0]) clearInterval(checkTarget1); } else { $.each(responses,function(i,t){ if(t.result_type == 'video'){ r.push(t) } }) } }, 50); clearInterval(checkTarget); } }, 50); } function setVideoInfo(tagList){ let videoList = $('.video-list.clearfix').children('.video-item.matrix') videoList.each(function(i,v){ let tags = tagList.data[i].tag.split(','); let typeName = tagList.data[i].typename; let title = $($($(v).children('.info')).children('.headline')).children('a').attr('title') title = replaceAllSymbol(title) let card = { tags: tags, typeName: typeName, card: $(v), title: title, }; videoInfo2.push(card) }) let checkTarget = setInterval(function () { if(videoInfo2.length > 19){ removeSearchVideo() clearInterval(checkTarget); } }, 50); } function removeSearchVideo(){ $.each(videoInfo2, function(i, v){ let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(v.tags, function(i1, tag){ if((BiliBiliTagsBlocker.tagsArray.includes(tag) || BiliBiliTagsBlocker.tagsArray.includes(v.typeName)) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.css({"display":"none"}); } } successed = true } }); } else{ $.each(v.tags, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if((tag.indexOf(t) != -1 || v.typeName.indexOf(t) != -1) && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(v.title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) } }); videoInfo2 = [] responses = [] } function removeUserVideo(){ let userVideoInfo = [] let videoListCard = $('.u-videos').children('.video-item') videoListCard.each(function(i,v){ let href = $(v).children('a').attr('href') let title = $($(v).children('.video-info')).children('a').text(); title = replaceAllSymbol(title) let videoCard = $(this); let bvInfo = { bv : 'BV'+getBvcountber(href), card : videoCard, title : title, } userVideoInfo.push(bvInfo) }) let checkTarget = setInterval(function () { if(userVideoInfo.length > 0 && BiliBiliTagsBlocker.tagsArray != null && BiliBiliTagsBlocker.tagsArray != undefined && BiliBiliTagsBlocker.tagsArray.length >= 1){ $.each(userVideoInfo, function(i, v){ $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+v.bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; $.each(tags.data,function(i,t){ $.each(t,function(i,tag){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.css({"display":"none"}); } } successed = true } }) }) if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(v.title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.remove(); } } successed = true } }) } }, }); }); clearInterval(checkTarget); } }, 50); } //==================搜索历史======================= function removeSearchHistory(){ $(document).arrive('.history-text', {fireOnAttributesModification: true, onceOnly: false, existing: true},function(){ let text = $(this).text(); if(BiliBiliTagsBlocker.tagsArray.includes(text)) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ $(this).parents('.history-item').css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ $(this).parents('.history-item').css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ $(this).parents('.history-item').remove(); } } } }) } //==================动态======================= function initPostVideoInfo(){ videoInfo = [] let postCardList = $(".bili-dyn-list__items").children(".bili-dyn-list__item"); $(postCardList).each(function(i){ let info = $(this).children(".bili-dyn-item").children(".bili-dyn-item__main").children(".bili-dyn-item__body").children(".bili-dyn-content").children(".bili-dyn-content__orig").children(".bili-dyn-content__orig__major").children("a"); let bv = getBvcountber($(info).attr("href")); let title = $(info).children('.bili-dyn-card-video__body'); if (title.length == 1){ title = title.children('.bili-dyn-card-video__title').text(); title = replaceAllSymbol(title) } else{ title = null; } let videoCard = $(this).children(".bili-dyn-item").children(".bili-dyn-item__main"); if(bv != undefined){ let bvInfo = { bv : "BV"+bv, card : $(this), color : videoCard, title : title, } videoInfo.push(bvInfo); } }); let checkTarget = setInterval(function () { if(videoInfo.length > 0 && BiliBiliTagsBlocker.tagsArray != null && BiliBiliTagsBlocker.tagsArray != undefined && BiliBiliTagsBlocker.tagsArray.length >= 1){ $.each(videoInfo, function(i, v){ $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+v.bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(tags.data,function(i,t){ $.each(t,function(i,tag){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.color.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.color.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.color.css({"display":"none"}); } } successed = true } }) }) } else{ $.each(tags.data, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if(tag.tag_name.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.color.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.color.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.color.css({"display":"none"}); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(v.title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.color.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.color.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.color.css({"display":"none"}); } } successed = true } }) } }, }); }); clearInterval(checkTarget); } }, 50); } function matchTopic(){ $(document).arrive('.relevant-topic__title', {fireOnAttributesModification: true, onceOnly: true, existing: true},function(){ let parent = $($(this).parents('.relevant-topic')); let title = $(this).text(); let successed = false; $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(title.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ parent.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ parent.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ parent.css({"display":"none"}); } } successed = true; } }) }) } //==================首页======================= function clickChangeAgain(){ //$('.page-item.active').children('button').click() //console.log($('.page-item.active').children('button')) $('div.change-btn').click() } function initHomeVideoInfo(videoList){ videoInfo = [] let insertList1 = [] if(!BiliBiliTagsBlocker.onlyChangeColorEnable){ setTimeout(function(){ $($('.rcmd-box')[0]).css({"justify-content":"flex-start"}) },100); } let videoCardList = $('.rcmd-box').children(); videoCardList.each(function(i){ if(i <= 9){ let href = $(this).children(".info-box").children("a").attr("href"); let videoCard = $(this); let videoCardTitle = $(this).children(".info-box").children("a").children("img").attr("alt") videoCardTitle = replaceAllSymbol(videoCardTitle) let bvInfo = { bv : 'BV'+getBvcountber(href), card : videoCard, title : videoCardTitle } videoInfo.push(bvInfo); } }); let checkTarget = setInterval(function () { if(videoInfo.length > 0 && BiliBiliTagsBlocker.tagsArray != null && BiliBiliTagsBlocker.tagsArray != undefined && BiliBiliTagsBlocker.tagsArray.length >= 1){ $.each(videoInfo, function(i, v){ $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+v.bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(tags.data,function(i,t){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.css({"display":"none"}); } } successed = true } }) } else{ $.each(tags.data, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if(tag.tag_name.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.card.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.card.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.card.css({"display":"none"}); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(v.title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ v.color.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ v.color.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ v.color.css({"display":"none"}); } } successed = true } }) } if(!successed && !BiliBiliTagsBlocker.onlyChangeColorEnable){ insertList1.push(v) $($('.rcmd-box')[0]).prepend(v.card) } }, }); }); clearInterval(checkTarget); } }, 50); if(!BiliBiliTagsBlocker.onlyChangeColorEnable){ let zoom = detectZoom() let insertList2 = [] let reverse = function(){ return new Promise(function(resolve){ let checkTarget1 = setInterval(function () { if(insertList1.length > 0){ $.each(insertList1, function(i, v){ insertList2.push(insertList1[insertList1.length-1-i]) }) clearInterval(checkTarget1); resolve(true); } }, 350); }); } reverse().then(function(data){ $.each(insertList2, function(i, v){ if(zoom < 100){ if(0 != i && 5 != i){ v.card.css({"margin-left":"10px"}) } } if(zoom >= 100 && zoom <= 135){ if(0 != i && 5 != i){ v.card.css({"margin-left":"10px"}) } } if(zoom >= 140 && zoom <= 150){ if(0 != i && 4 != i){ v.card.css({"margin-left":"10px"}) } } if(zoom > 150){ if(0 != i && 3 != i){ v.card.css({"margin-left":"10px"}) } } }) }) } } //==================动态导航栏==================== function initNavbarListener(){ var targetNode = $('.video-list')[0]; var options = {childList: true,attributes :true}; function callback(mutationsList, observer) { if(mutationsList.length >= 1 && mutationsList[0].addedNodes.length!=0){ $.each(mutationsList, function(i, m){ initNavbarVideoInfo(m.addedNodes[0]) }); } } let mutationObserver = new MutationObserver(callback); let checkTarget = setInterval(function () { if(targetNode != undefined && targetNode != null){ mutationObserver.observe(targetNode, options); clearInterval(checkTarget); $.each($(targetNode).children(".list-item"), function(i, m){ initNavbarVideoInfo(m) }); } }, 50); } function initNavbarVideoInfo(card){ let href = $(card).children(".main-container").children("a").attr("href"); let title = $(card).children(".main-container").children(".center-box").children("a").attr('title') title = replaceAllSymbol(title) let videoCard = $(card); let bv = getBvcountber(href) $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid="+bv, { method: 'GET', headers: { "content-type": "application/json" }, async: true, success: function (tags) { let successed = false; if(!BiliBiliTagsBlocker.fuzzyMatch){ $.each(tags.data,function(i,t){ if(BiliBiliTagsBlocker.tagsArray.includes(t.tag_name) && !successed) {//includes 检测数组是否有某个值 if(BiliBiliTagsBlocker.onlyChangeColorEnable){ videoCard.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ videoCard.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ videoCard.remove(); } } successed = true } }) } else{ $.each(tags.data, function(i1, tag){ $.each(BiliBiliTagsBlocker.tagsArray,function(i,t){ if(tag.tag_name.indexOf(t) != -1 && !successed){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ videoCard.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ videoCard.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ videoCard.remove(); } } successed = true } }) }); } if(BiliBiliTagsBlocker.matchTitle && !successed){ $.each(BiliBiliTagsBlocker.titlesArray,function(i,t){ if(title.indexOf(t) != -1){ if(BiliBiliTagsBlocker.onlyChangeColorEnable){ videoCard.css({"background":"blue"}) }else{ if(BiliBiliTagsBlocker.blurMode){ videoCard.css({"filter":"blur(1rem)"}); } if(BiliBiliTagsBlocker.hiddenMode){ videoCard.remove(); } } successed = true } }) } }, }); } //==================other==================== //重设界面 //0,收起 1,展开 var buttonState = 0 var buttonState2 = 0 var responses = [] function reSetUI(){ //$('.block_obj_wrap_div').css({"width":"auto"}) //$('#blockObj_BiliBiliTagsBlocker_mainFieldset').css({"background-color":""}) $($('#blockObj_BiliBiliTagsBlocker_ulNode')[0]).append('取消'); let parent = $($('#blockObj_BiliBiliTagsBlocker_version')[0]).parent() parent.css("display","flex") let countKeys = BiliBiliTagsBlocker.tagsArray.length+BiliBiliTagsBlocker.titlesArray.length parent.append('当前共屏蔽'+ countKeys +'个标签') let ver = $($('#blockObj_BiliBiliTagsBlocker_version')[0]) ver.css("width","73%") let expand = $($(".block_obj_input_btn")[4]) let targetNode = $($('.block_obj_list_textarea_div')[0]); let checkTarget = setInterval(function () { expand = $($(".block_obj_input_btn")[4]) if(targetNode != undefined && targetNode != null){ targetNode.css('max-height','69') if(expand.attr("title") == '展开列表'){ expand.click(function(){ if(buttonState == 0){ targetNode.animate({ maxHeight: 300, opacity: 'show' }, "slow"); buttonState = 1 } else if(buttonState == 1){ targetNode.animate({ maxHeight: 69, opacity: 'show' }, "slow"); buttonState = 0 } }); } clearInterval(checkTarget); } }, 50); let expand2 = $($(".block_obj_input_btn")[9]) let targetNode2 = $($('.block_obj_list_textarea_div')[1]); let checkTarget2 = setInterval(function () { expand2 = $($(".block_obj_input_btn")[9]) if(targetNode2 != undefined && targetNode2 != null){ targetNode2.css('max-height','69') if(expand2.attr("title") == '展开列表'){ expand2.click(function(){ if(buttonState2 == 0){ targetNode2.animate({ maxHeight: 300, opacity: 'show' }, "slow"); buttonState2 = 1 } else if(buttonState2 == 1){ targetNode2.animate({ maxHeight: 69, opacity: 'show' }, "slow"); buttonState2 = 0 } }); } clearInterval(checkTarget2); } }, 50); let cancel2 = $($("#cancel2")[0]) $($('.block_obj_button')[2]).remove() cancel2.click(function(){ let main = $($("#blockObj_BiliBiliTagsBlocker_wrapDiv")[0]) main.removeClass('block_obj_wrap_div block_obj_show_wrap') main.addClass('block_obj_wrap_div block_obj_hidden_wrap') }); if (window.parent == window) { // 当前页面不在iframe中 } else { // 当前页面在iframe或者frameset中 $("#blockObj_BiliBiliTagsBlocker_expandSpan").animate({ opacity: 'hide' }, 200); } } if (window.parent == window) { // 当前页面不在iframe中 ajaxHook(); } else { // 当前页面在iframe或者frameset中 } function ajaxHook() { ah.proxy( { onResponse: (response, handler) => { //搜索页 例/all?keyword=原神 if (!response.config.url.includes('/web-interface/search/default') && !response.config.url.includes('/web-interface/search/square') && response.config.url.includes('/web-interface/search')){ let data = JSON.parse(response.response).data if(data.result.length == 11){ responses.push(data.result[data.result.length-1]) } if(data.result.length == 20){ let data1 = { data: data.result, result_type: 'video' } responses.push(data1) } initSearchVideoInfo() setTimeout(function(){ removeUserVideo() },100); } //热门页面 if (response.config.url.includes('/web-interface/popular')){ initPopularVideoInfo(response.config.url) } //排行榜 if (response.config.url.includes('rank')){ let data = JSON.parse(response.response); initRankVideoInfo() } //首页 if (response.config.url.includes('web-interface/index/top/rcmd')){ let data = JSON.parse(response.response).data; setTimeout(function(){ initHomeVideoInfo(data.item) },50); } //动态 if (response.config.url.includes('web-dynamic/v1/feed/all')){ setTimeout(function(){ initPostVideoInfo() },50); } handler.next(response); }, }, unsafeWindow ); } //移除所有符号 var symbols = [' ','♂','【','】'] function replaceAllSymbol(title) { $.each(symbols,function(i,k){ if(title.indexOf(k) != -1){ title = title.replaceAll(k,'') } }) return title; } //通过url获得BV号 function getBvcountber(video_link) { let bvcount = ''; try { bvcount = /\/video\/(?:av|bv)(\w+)/i.exec(video_link)[1]; } catch (e) { bvcount = null; } return bvcount; } //获取当前缩放比例 function detectZoom() { var ratio = 0, screen = window.screen, ua = navigator.userAgent.toLowerCase(); if (window.devicePixelRatio !== undefined) { ratio = window.devicePixelRatio; } else if (~ua.indexOf('msie')) { if (screen.deviceXDPI && screen.logicalXDPI) { ratio = screen.deviceXDPI / screen.logicalXDPI; } } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) { ratio = window.outerWidth / window.innerWidth; } if (ratio) { ratio = Math.round(ratio * 100); } return ratio; } //检查jQuery var checkJQuery = function () { let jqueryCdns = [ 'http://code.jquery.com/jquery-2.1.4.min.js', 'https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', 'https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js', 'https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js', ]; function isJQueryValid() { try { let wd = unsafeWindow; if (wd.jQuery && !wd.$) { wd.$ = wd.jQuery; } $(); return true; } catch (exception) { return false; } } function insertJQuery(url) { setTimeout(function(){ let checkJQuery = setInterval(function () { if(document == undefined && document != null && document.createElement('script') == undefined && document.createElement('script') != null){ let script = document.createElement('script'); script.src = url; document.head.appendChild(script); return script; clearInterval(checkJQuery); } }, 100); },500); } function converProtocolIfNeeded(url) { let isHttps = location.href.indexOf('https://') != -1; let urlIsHttps = url.indexOf('https://') != -1; return script; if (isHttps && !urlIsHttps) { return url.replace('http://', 'https://'); } else if (!isHttps && urlIsHttps) { return url.replace('https://', 'http://'); } return url; } function waitAndCheckJQuery(cdnIndex, resolve) { if (cdnIndex >= jqueryCdns.length) { iLog.e('无法加载 JQuery,正在退出。'); resolve(false); return; } let url = converProtocolIfNeeded(jqueryCdns[cdnIndex]); iLog.i('尝试第 ' + (cdnIndex + 1) + ' 个 JQuery CDN:' + url + '。'); let script = insertJQuery(url); setTimeout(function () { if (isJQueryValid()) { iLog.i('已加载 JQuery。'); resolve(true); } else { iLog.w('无法访问。'); script.remove(); waitAndCheckJQuery(cdnIndex + 1, resolve); } }, 100); } return new Promise(function (resolve) { if (isJQueryValid()) { iLog.i('已加载 jQuery。'); resolve(true); } else { iLog.i('未发现 JQuery,尝试加载。'); waitAndCheckJQuery(0, resolve); } }); } let checkSetting = setInterval(function () { BiliBiliTagsBlocker = blockObj.getConfig(); if(BiliBiliTagsBlocker.tagsArray != null){ clearInterval(checkSetting); } }, 500); function ILog() { this.prefix = ''; this.v = function (value) { if (level <= this.LogLevel.Verbose) { console.log(this.prefix + value); } } this.i = function (info) { if (level <= this.LogLevel.Info) { console.info(this.prefix + info); } } this.w = function (warning) { if (level <= this.LogLevel.Warning) { console.warn(this.prefix + warning); } } this.e = function (error) { if (level <= this.LogLevel.Error) { console.error(this.prefix + error); } } this.d = function (element) { if (level <= this.LogLevel.Verbose) { console.log(element); } } this.setLogLevel = function (logLevel) { level = logLevel; } this.LogLevel = { Verbose: 0, Info: 1, Warning: 2, Error: 3, }; let level = this.LogLevel.Verbose; } let inChecking = false; let matchSuccess = false; let jqItv = setInterval(function () { if (inChecking) { return; } inChecking = true; checkJQuery().then(function (isLoad) { if (isLoad) { if(BiliBiliTagsBlocker.functionEnable){ console.log("已启用Tags屏蔽"); initNavbarListener(); }else{ console.log("已关闭Tags屏蔽"); } if (matchSearch && BiliBiliTagsBlocker.functionEnable && !matchSuccess) { matchSuccess = true; if(BiliBiliTagsBlocker.removeSearchTrend){ removeTrend(); } if(BiliBiliTagsBlocker.removeSearchHistory){ removeSearchHistory(); } clickSearchAgain(); } if (matchVideo && BiliBiliTagsBlocker.functionEnable && !matchSuccess) { matchSuccess = true; initVideoListener() if(BiliBiliTagsBlocker.removeNextVideo){ initNextVideoListener() } if(BiliBiliTagsBlocker.removeEndVideo){ removeEndVideo() } if(BiliBiliTagsBlocker.removeAllAD){ removeRightBanner() removeLive() removeBottomActivity() } if(BiliBiliTagsBlocker.removeVideoPopupBox){ removeVideoPopupBox() } removeAdVideo() } if (matchRank && BiliBiliTagsBlocker.functionEnable && !matchSuccess) { matchSuccess = true; initRankVideoInfo() } if (matchPost && BiliBiliTagsBlocker.functionEnable && !matchSuccess) { matchSuccess = true; if(BiliBiliTagsBlocker.matchTopic){ matchTopic() } } if (matchHome && BiliBiliTagsBlocker.functionEnable && !matchSuccess) { matchSuccess = true; clickChangeAgain() } if(BiliBiliTagsBlocker.functionEnable != undefined){ reSetUI() clearInterval(jqItv); } } inChecking = false; }); }, 500); var iLog = new ILog();