Acfun过滤UP计划

帮助你屏蔽不想看的UP主

目前为 2019-04-07 提交的版本。查看 最新版本

// ==UserScript==
// @name         Acfun过滤UP计划
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  帮助你屏蔽不想看的UP主
// @author       人文情怀
// @match        http://www.acfun.cn/a/ac*
// @match        http://www.acfun.cn
// @match        http://www.acfun.cn/v/list*
// @grant        none
// ==/UserScript==



(function() {
    'use strict';

    //这里输入所有的up主用户名,请按照格式自己编辑
    let up=[
        "Devul coat",
        "一只撸狗",
        "美食作家王刚",
        "只要ID名字哟",
        "Acfun的文字ID就好,UID不行",
        "随便输入只要用同样的格式",
    ];

    //
    console.log("match type", window.location.href)

    function usernameByTitle(title){
        let regex = /UP:(.+)[\s\v\n]/g
        return title.match(regex);
    }

    function FilterVideos(upList){

        //过滤主页视频
        let selections = $("a[data-info]");
        for (let i=0;i<selections.length;i++){
            let tag=selections[i];
            let info=$(tag).attr("data-info");
            let json=JSON.parse(info);
            let username=json.userName;
            if (upList.indexOf(username)>=0){
                $(tag).parent().css("visibility","hidden");
            }
        }
        //过滤右边排行榜视频
        let sel=$("ul[data-con]");

        //For each rank
        for (let i=0;i<sel.length;i++){
            let tag=sel[i];
            let rows=$(tag).find("li");
            //For each row
            for (let ri=0;ri<rows.length;ri++){
                let rowTag = rows[ri];
                let aTag = $(rowTag).find("[title]")[0];
                let title=$(aTag).attr("title");
                let matches = usernameByTitle(title)
                if (matches){
                    let username = matches[0].substring(3).trim();
                    if (upList.indexOf(username)>=0){
                        //找到了,隐藏本条
                        $(rowTag).css("visibility","hidden");
                    }
                }
            }
        }
    }

    //过滤主页文章区
    function FilterArticles(upList){
        let sel=$("div[data-con]");
        for (let i=0;i<sel.length;i++){
            let tag=sel[i];
            let rows=$(tag).find("li");
            //For each row
            for (let ri=0;ri<rows.length;ri++){
                let rowTag = rows[ri];
                let aTag = $(rowTag).find("[title]")[0];
                let title=$(aTag).attr("title");
                if (title){
                    let matches = usernameByTitle(title)
                    if (matches){
                        let username = matches[0].substring(3).trim();
                        if (upList.indexOf(username)>=0){
                            //找到了,隐藏本条
                            console.log("过滤文脏区 rank=", i, "row=",ri,"username=",username);
                            $(rowTag).css("visibility","hidden");
                        }
                    }
                }
            }
        }
    }

    //过滤文章列表页
    function FilterListPage(upList){
        let sel=$("div.weblog-item");
        for (let i = 0;i<sel.length;i++){
            let row = sel[i];
            if (typeof row.visited=="undefined"){ row.visited = true; }else{continue;}
            let aTag = $(row).find(".atc-up")[0];
            let username = $(aTag).attr("title");

            if (upList.indexOf(username)>=0){
                console.log("过滤文脏区",username);
                //屏蔽
                //$(row).css("display","none");
                //$(row).removeClass("wblog-item");
                //或者删除
                $(row).remove();
            }
        }
    }
    function HandleHomePage(){
        //屏蔽首页UP,包括视频和右边的文章区
        FilterVideos(up);
        FilterArticles(up);

        setTimeout(HandleHomePage, 800);
    }
    function HandleListPage(){
        //屏蔽文章页,
        FilterListPage(up);
        setTimeout(HandleListPage, 500);
    }
    $(document).ready(function(){
        if (window.location.href=="http://www.acfun.cn/"){
            HandleHomePage();
        }
        if (window.location.href.indexOf("www.acfun.cn/v/list")>=0){
            HandleListPage();
        }

    })

})();

QingJ © 2025

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