BiliBili Tags Blocker BiliBili标签屏蔽助手

眼不见为净,耳不听为清,心不想则静

目前为 2022-08-07 提交的版本。查看 最新版本

// ==UserScript==
// @name         BiliBili Tags Blocker BiliBili标签屏蔽助手
// @namespace    https://gf.qytechs.cn/zh-CN/users/924205-xiao-xi
// @version      0.6.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/[email protected]/dist/ajaxhook.min.js
// @require      https://gf.qytechs.cn/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
// ==/UserScript==
// https://gf.qytechs.cn/zh-CN/scripts/417760-checkjquery
var BiliBiliTagsBlocker = {
    functionEnable: true,
    onlyChangeColorEnable: false,
    removeSpecialEnable: false,
    removeNextVideo: false,
    homeCover: false,
    removeRightBanner: false,
    removeLive: false,
    removeBottomActivity: false,
    blurMode: false,
    hiddenMode: false,
    tagsArray: [],
};
const BASIC_STYLE = `
     .block_obj_checkbox_label {
         padding-left: 13px;
     }
  `;
let blockObj = new Block_Obj('BiliBili_Tags_Blocker');
function initSettingUI(){
    if(!isCheckSetting){
        blockObj.init({
            id: 'BiliBiliTagsBlocker',
            menu: 'Tags屏蔽设置',
            style: BASIC_STYLE,
            field: [
                {
                    id: 'version',
                    label: 'v0.6.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,
                },
                {
                    label: '首页设置',
                    type: 's',
                },
                {
                    id: 'homeCover',
                    label: '首页遮罩(暂时移除)',
                    title: '加载图',
                    type: 'c',
                    default: false,
                },
                {
                    label: '视频页设置',
                    type: 's',
                },
                {
                    id: 'removeSpecialEnable',
                    label: '移除特别推荐',
                    title: '多为推广',
                    type: 'c',
                    default: false,
                },
                {
                    id: 'removeNextVideo',
                    label: '移除接下来播放',
                    title: '推荐的什么jb',
                    type: 'c',
                    default: false,
                },
                {
                    id: 'removeRightBanner',
                    label: '移除右下角推广',
                    title: '推荐的什么jb',
                    type: 'c',
                    default: false,
                },
                {
                    id: 'removeLive',
                    label: '移除直播推荐',
                    title: '推荐的什么jb',
                    type: 'c',
                    default: false,
                },
                {
                    id: 'removeBottomActivity',
                    label: '移除视频下方活动',
                    title: '什么jb玩意',
                    type: 'c',
                    default: false,
                },
                {
                    label: 'Tag设置',
                    type: 's',
                },
                {
                    id: 'tagInput',
                    label: '输入:',
                    placeholder: ' 同时输入多个时以英文逗号分隔 ',
                    type: 'i',
                    list_id: 'tagsArray',
                },
                {
                    id: 'tagsArray',
                    type: 'l',
                    default: [],
                },
            ],
            events: {
                save: config => {
                    BiliBiliTagsBlocker = config;
                },
                change: config => {
                    BiliBiliTagsBlocker = config;
                },
            },
        });
    }
    isCheckSetting = true;
}
//视频信息
var videoInfo = [];
var oldVideoInfo = [];
var isLoading = false;
let href = location.href;
let matchSearch = href.match(/search.bilibili/);
let matchPopular = href.match(/popular/);
let matchPost = href.match(/t.bilibili/);
let matchVideo = href.match(/video/);
let matchHome = href.match(/bilibili.com/);

//=======================通用=========================

//获取视频信息
function initvideoInfo(match,parameter){
    let loaded = 0;
    if(match == "video"){
        let videoCardList = $(parameter).children(".video-page-card");
        videoCardList.each(function(i){
            let href = $(this).children(".card-box").children(".info").children("a").attr("href");
            let videoCard = $(this);
            let videoCardTitle = $(this).children(".card-box").children(".info").children("a").children("span").attr("title");
            let bvInfo = {
                bv : getBvcountber(href),
                index : i,
                card : videoCard,
                title : videoCardTitle,
            }
            loaded++;
            videoInfo.push(bvInfo);
        });

    }
    if(match == "video-reload"){
        let videoCardList = $(parameter);
        videoCardList.each(function(i){
            let href = $(this).children(".card-box").children(".info").children("a").attr("href");
            let videoCard = $(this);
            let videoCardTitle = $(this).children(".card-box").children(".info").children("a").children("span").attr("title");
            let bvInfo = {
                bv : getBvcountber(href),
                card : videoCard,
                title : videoCardTitle,
            }
            loaded++;
            videoInfo.push(bvInfo);
        });

    }
    return new Promise(function (isLoad) {
        let checkvideoInfo = setInterval(function () {
            $.each(videoInfo, function(i, v){
                if(loaded == videoInfo.length){
                    clearInterval(checkvideoInfo);
                    isLoad(true);
                }
            });
        }, 500);
    });
}

//获取视频Tag信息
function initVideoTagInfo() {
    let loaded = false;
    $.each(videoInfo, function(i, b){
        $.ajax("https://api.bilibili.com/x/web-interface/view/detail/tag?bvid=BV"+b.bv, {
            method: 'GET',
            headers: {
                "content-type": "application/json"
            },
            async: true,
            success: function (tags) {
                let tagInfo = {
                    tags : tags
                }
                b["Tags"] = tagInfo;
                let r = {
                    isRemove : false
                }
                b["isRemove"] = r;
            },
        });
    });

    return new Promise(function (isLoad) {
        let checkTagsInfo = setInterval(function () {
            $.each(videoInfo, function(i, v){
                if (v.hasOwnProperty("Tags") && v.Tags.hasOwnProperty("tags") && videoInfo[0].hasOwnProperty("isRemove")) {
                    if (v.Tags.tags.hasOwnProperty("data")) {
                        if(i == videoInfo.length-1){
                            clearInterval(checkTagsInfo);
                            isLoad(true);
                        }
                    }
                }

            });
        }, 500);
    });
}
//设置需要删除的视频
function setRemoveVideo(){
    let loaded = 0;
    $.each(videoInfo, function(i, v){
        loaded++;
        if (v.hasOwnProperty("Tags") && v.Tags.hasOwnProperty("tags") && videoInfo[0].hasOwnProperty("isRemove")) {
            if (v.Tags.tags.hasOwnProperty("data") && v.Tags.tags.data.length > 0) {
                $.each(v.Tags.tags.data, function(i, t){
                    $.each(BiliBiliTagsBlocker.tagsArray, function(i, bt){
                        if(bt == t.tag_name){
                            let r = {
                                isRemove : true
                            }
                            v["isRemove"] = r;
                        }
                    });
                });
            }
        }
    });
    return new Promise(function (isLoad) {
        let checkTagsInfo = setInterval(function () {
            if (videoInfo.length == loaded) {
                clearInterval(checkTagsInfo);
                isLoad(true);
            }
        }, 500);
    });

}
//删除网页中的视频
function removeVideo(match){
    let zoom = detectZoom()
    $.each(videoInfo, function(i, v){
        if(v.hasOwnProperty("isRemove") && v.isRemove.hasOwnProperty("isRemove")  && v.isRemove.isRemove && oldVideoInfo != videoInfo){
            if(match == "video"){
                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"});
                    }
                }
            }
        }
    });
}

function Remove(init_match,remove_match,parameter){
    isLoading = true;
    initvideoInfo(init_match,parameter).then(function (resolve) {
        initVideoTagInfo().then(function (resolve) {
            setRemoveVideo().then(function (resolve) {
                removeVideo(remove_match)
                if(BiliBiliTagsBlocker.homeCover && matchHome){
                    $('#cover').remove()
                }
                isLoading = false;
            });
        });
    });
}

//==============视频页================
function initVideoListener(){

    var targetNode = $('.rec-list')[0];
    var options = {childList: true};
    function callback(mutationsList, observer) {
        if(mutationsList.length >= 1 && mutationsList[0].addedNodes.length!=0 && isLoading == false){
            oldVideoInfo = videoInfo;
            videoInfo = [];
            isLoading = true
            let cardList = [];
            $.each(mutationsList, function(i, m){
                cardList.push(m.addedNodes[0]);
            });
            Remove("video-reload","video",cardList);
        }
    }
    let mutationObserver = new MutationObserver(callback);
    let checkTarget = setInterval(function () {
        if(targetNode !=  undefined && targetNode !=  null){
            mutationObserver.observe(targetNode, options);
            clearInterval(checkTarget);
            if(BiliBiliTagsBlocker.removeSpecialEnable){
                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"});
                    }
                }
            }
            Remove("video","video",targetNode);

        }

    }, 50);
}
//接下来播放
function initNextVideoListener(){
    var targetNode = $('#reco_list')[0]
    let checkTarget = setInterval(function () {
        if(targetNode !=  undefined && targetNode !=  null){
            let next = $(targetNode).children('.next-play')
            if (BiliBiliTagsBlocker.onlyChangeColorEnable) {
                next.css({"background":"blue"})
            }
            else
            {
                next.css({"display":"none"})
            }
            clearInterval(checkTarget);
        }

    }, 50);
}
//右下角推广
function removeRightBanner(){
    var targetNode = $('#right-bottom-banner')[0];
    let checkTarget = setInterval(function () {
        targetNode = $('#right-bottom-banner')[0];
        if(targetNode !=  undefined && targetNode !=  null){
            setTimeout(function(){
                $("#right-bottom-banner").css("display","none");
            },500);
            clearInterval(checkTarget);
        }

    }, 300);
}
//右下角直播
function removeLive(){
    var targetNode = $('#live_recommand_report')[0];
    let checkTarget = setInterval(function () {
        targetNode = $('#live_recommand_report')[0];
        if(targetNode !=  undefined && targetNode !=  null){
            $(targetNode).css({ "display": "none"});
            clearInterval(checkTarget);
        }

    }, 300);
}
//视频下方活动
function removeBottomActivity(){
    var targetNode = $('#activity_vote')[0];
    let count = 0
    let checkTarget = setInterval(function () {
        count += 1
        targetNode = $('#activity_vote')[0];
        if(targetNode !=  undefined && targetNode !=  null){
            $(targetNode).css({ "display": "none"});
            clearInterval(checkTarget);
        }
        if (count >= 10)
        {
            clearInterval(checkTarget);
        }
    }, 500);
}

//=======================热门页面=========================

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 bvInfo = {
                    bv : "BV"+getBvcountber(href),
                    card : videoCard,
                }
                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;
                        $.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
                                }
                            })

                        })
                    },
                });
            });
            clearInterval(checkTarget1);
        }
    }, 50);
}

//==================搜索页面=======================
var videoInfo2 = []
//手动请求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 card = {
            tags: tags,
            card: $(v)
        };
        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;
        $.each(v.tags, function(i1, tag){
            if(BiliBiliTagsBlocker.tagsArray.includes(tag) && !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
            }
        });

    });
    videoInfo2 = []
    responses = []
}


//==================动态=======================
function initPostVideoInfo(){
    videoInfo = []
    let postCardList = $(".bili-dyn-list__items").children(".bili-dyn-list__item");
    $(postCardList).each(function(i){
        let bv = getBvcountber($(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").attr("href"));
        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 : "",
            }
            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;
                        $.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
                                }
                            })

                        })
                    },
                });
            });
            clearInterval(checkTarget);
        }
    }, 50);
}

//==================首页=======================

var home_first = false;

function initHomeListener(){
    var targetNode = $('.rcmd-box')[0];
    var options = {childList: true,attributes :true};
    function callback(mutationsList, observer) {

        $.each(mutationsList, function(i, m){
            if(m.addedNodes.length!=0  && isLoading == false && home_first == true)
            {
                isLoading = true;
                oldVideoInfo = videoInfo;
                videoInfo = [];
                setTimeout(function(){
                    Remove("home","home",null);
                },300);
            }
        })

    }
    let src = 'https://s2.loli.net/2022/08/04/G1YVrxT6vCsPgBW.jpg'
    let first = true
    let mutationObserver = new MutationObserver(callback);
    let checkTarget = setInterval(function () {
        if(targetNode !=  undefined && targetNode !=  null && first){
            if(BiliBiliTagsBlocker.homeCover){
                let w = $($('.rcmd-box-wrap')[0]).width()
                let h = $($('.rcmd-box-wrap')[0]).height()
                $($('.rcmd-box-wrap')[0]).prepend('<img id="cover" style="position:absolute;width:'+ w +'px;height:'+ h +'px;z-index:999999;top: 0;left: 0;" src="' + src + '" />');
                $(".change-btn").click(function(){
                    let w = $($('.rcmd-box-wrap')[0]).width()
                    let h = $($('.rcmd-box-wrap')[0]).height()
                    $($('.rcmd-box-wrap')[0]).prepend('<img id="cover" style="position:absolute;width:'+ w +'px;height:'+ h +'px;z-index:999999;top: 0;left: 0;" src="' + src + '" />');
                });
            }
            if(!BiliBiliTagsBlocker.onlyChangeColorEnable){
                setTimeout(function(){
                    $($('.rcmd-box')[0]).css({"justify-content":"flex-start"})
                },100);
            }
            first = false
            Remove("home","home",null);
        }
        if(home_first){
            mutationObserver.observe(targetNode, options);
            clearInterval(checkTarget);
        }
    }, 500);
}

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")
            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;
                        $.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(!successed && !BiliBiliTagsBlocker.onlyChangeColorEnable){
                            insertList1.push(v)
                            $($('.rcmd-box')[0]).prepend(v.card)
                        }
                    },
                });
            });
            clearInterval(checkTarget);
        }
    }, 50);
    if(!BiliBiliTagsBlocker.onlyChangeColorEnable){
        let zoom = detectZoom()
        setTimeout(function(){
            insertList1 = insertList1.reverse();
            $.each(insertList1, 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"})
                    }
                }
            })
        },300);
    }
}

//==================动态导航栏====================
function initNavbarPostVideoInfo(){
    let videoCardList = $('.video-list').children(".list-item");
    videoCardList.each(function(i){
        let href = $(this).children(".main-container").children("a").attr("href");
        let videoCard = $(this);
        let videoCardTitle = $(this).attr("title")
        let bvInfo = {
            bv : "BV"+getBvcountber(href),
            card : videoCard,
        }
        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;
                        $.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
                                }
                            })

                        })
                    },
                });
            });
            clearInterval(checkTarget);
        }
    }, 50);
}

//==================other====================
//重设界面
//0,收起 1,展开
var buttonState = 0

var responses = []

function reSetUI(){
    $($('#blockObj_BiliBiliTagsBlocker_ulNode')[0]).append('<span id="cancel2" class="block_obj_button" style="float: left;margin-left: 5px;">取消<span/>');
    let parent = $($('#blockObj_BiliBiliTagsBlocker_version')[0]).parent()
    parent.css("display","flex")
    parent.append('<span class="block_obj_separator_text" style="">当前共屏蔽'+ BiliBiliTagsBlocker.tagsArray.length +'个标签<span/>')
    let ver = $($('#blockObj_BiliBiliTagsBlocker_version')[0])
    ver.css("width","73%")
    let count = 0
    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(){
                    count += 1
                    if(buttonState == 0){
                        targetNode.animate({
                            maxHeight: 300, opacity: 'show'
                        }, "slow");
                    }
                    if(buttonState == 1){
                        targetNode.animate({
                            maxHeight: 69, opacity: 'show'
                        }, "slow");
                    }
                    if(buttonState == 0){
                        buttonState = 1
                    }
                    else{
                        buttonState = 0
                    }
                });
            }
            clearInterval(checkTarget);
        }

    }, 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')
    });
}

ajaxHook();
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')){
                    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()

                }
                //热门页面
                if (response.config.url.includes('/web-interface/popular')){
                    initPopularVideoInfo(response.config.url)
                }
                //首页
                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);

                }
                //动态导航栏
                if (response.config.url.includes('dynamic_svr/v1/dynamic_svr')){
                    setTimeout(function(){
                        initNavbarPostVideoInfo()
                    },50);

                }
                handler.next(response);[]
            },
        },
        unsafeWindow
    );

}

//let checkTarget = setInterval(function () {
//  console.log($(".block_obj_input_btn")[4]);
//}, 2500);


//通过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 isCheckSetting = false;
let inChecking = false;
let matchSuccess = false;
let jqItv = setInterval(function () {
    if (inChecking) {
        return;
    }
    inChecking = true;
    checkJQuery().then(function (isLoad) {
        if (isLoad)
        {
            initSettingUI()
            if(BiliBiliTagsBlocker.functionEnable){
                console.log("已启用Tags屏蔽");
            }else{
                console.log("已关闭Tags屏蔽");
            }
            if (BiliBiliTagsBlocker.functionEnable) {
                //initNavbarListener();
            }
            if (matchSearch && BiliBiliTagsBlocker.functionEnable && !matchSuccess) {
                matchSuccess = true;
                clickSearchAgain();
            }
            if (matchPopular && BiliBiliTagsBlocker.functionEnable && !matchSuccess) {
                matchSuccess = true;
            }
            if (matchPost && BiliBiliTagsBlocker.functionEnable && !matchSuccess) {
                matchSuccess = true;
            }
            if (matchVideo && BiliBiliTagsBlocker.functionEnable && !matchSuccess) {
                matchSuccess = true;
                initVideoListener()
                if(BiliBiliTagsBlocker.removeNextVideo){
                    initNextVideoListener()
                }
                if(BiliBiliTagsBlocker.removeRightBanner){
                    removeRightBanner()
                }
                if(BiliBiliTagsBlocker.removeLive){
                    removeLive()
                }
                if(BiliBiliTagsBlocker.removeBottomActivity){
                    removeBottomActivity()
                }
            }
            if (matchHome && BiliBiliTagsBlocker.functionEnable && !matchSuccess) {
                matchSuccess = true;
                clickChangeAgain()
            }
            if(BiliBiliTagsBlocker.functionEnable != undefined){
                reSetUI()
                clearInterval(jqItv);
            }

        }
        inChecking = false;
    });
}, 500);
var iLog = new ILog();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址