Greasy Fork

Greasy Fork is available in English.

Acfun屏蔽计划

帮助你屏蔽不想看的UP主

当前为 2022-08-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Acfun屏蔽计划
// @namespace    http://tampermonkey.net/
// @version      3.003
// @author       人文情怀
// @exclude      https://www.acfun.cn/login/*
// @exclude      http://www.acfun.cn/login/*
// @match        http://www.acfun.cn/a/ac*
// @match        http://www.acfun.cn/v/list63
// @match        https://www.acfun.cn/a/ac*
// @match        http://www.acfun.cn/*
// @match        https://www.acfun.cn/*
// @match        https://www.acfun.cn/v/list*
// @match        http://www.acfun.cn/a/ac*
// @match        https://www.acfun.cn/a/ac*
// @match        http://www.acfun.cn/v/ac*
// @match        https://www.acfun.cn/v/ac*
// @match        https://www.acfun.cn/v/as*
// @match        http://www.acfun.cn/v/as*
// @connect      greasyfork.org
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM.getValue
// @grant        GM.setValue
// @grant        GM_deleteValue
// @grant        GM.deleteValue
// @grant        GM_xmlhttpRequest
// @grant        GM.xmlHttpRequest
// @grant        unsafeWindow
// @run-at      document-idle
// @description 帮助你屏蔽不想看的UP主
// @license     MIT
// ==/UserScript==

//  添加上面的exclude两行表示这个脚本不会在登陆页面出现
//这只是个代码下载器,用来下载正式的代码,具体想了解代码的人可以自己去看看。
(function(){


    let dev = false;

    let empty = (a) => {
        return typeof a === "undefined" ? () => {
            console.log("EmptyFunction Called");
            console.trace();
        } : a;
    };
    let GM_set = typeof GM_setValue === "undefined" ?
        function (key, value, callback, failcallback) {
            let p = GM.setValue(key, value);
            p.then(empty(callback), empty(failcallback));


        }
    : function (key, value, callback) {
        let res = GM_setValue(key, value);
        callback();
    };


    let GM_get = typeof GM_getValue === "undefined" ?
        function (key, value, callback) {
            let p = GM.getValue(key, value);
            p.then((debug) => {
                empty(callback)(debug);
            }, () => {
                callback(value);
            });
            //console.log("empty", empty(callback));
        }
    : function (key, value, callback, failcallback) {
        let res = GM_getValue(key, value);
        callback(res);
    };

    let xhttp = typeof GM_xmlhttpRequest !== "undefined" ? GM_xmlhttpRequest : GM.xmlHttpRequest;

    //下载代码并运行
    function downloadScript(callback){

        //开源地址
        let url1 =  "http://greasyfork.icu/scripts/387296-acfun%E5%B1%8F%E8%94%BD%E8%AE%A1%E5%88%92-%E5%BC%80%E6%BA%90%E4%BB%A3%E7%A0%81/code/Acfun%E5%B1%8F%E8%94%BD%E8%AE%A1%E5%88%92-%E5%BC%80%E6%BA%90%E4%BB%A3%E7%A0%81.user.js";
        //备用开源地址
        let url2 =  "https://github.com/baldhumanity/AcfunComplement/raw/master/acfunBlock-opensource.user.js";
        //debug url
        let url3 = "http://localhost:8080/acfunhelper.build.js?time="+(+new Date());

        let fallbackurl = dev ? url3 : url2;

        let fallback = ()=>{
            console.log("下载失败,启用备用链接");
            xhttp({
                nocache:true,
                method: "GET",
                url:fallbackurl,
                onload: function (response) {
                    let text = response.responseText;
                    callback(text);
                },
                onerror(evt) {
                    callback(null);
                }
            });

        }
        xhttp({
            nocache:true,
            method: "GET",
            url:url1,
            onload: function (response) {
                let text = response.responseText;

                callback(text);
            },
            onerror(evt) {
                fallback();
            }
        });
    }

    function getVersion(s){
        try{
            if (typeof s === "undefined" || s==null || s==="undefined" || s==="") return 0;
            let p = /@version +(\d+\.\d+)/;
            let arr = p.exec(s);
            let latest = arr[1];
            return parseFloat(latest);
        }catch(e){
            return 0;
        }
    }


    function Initialise(){
        //Check if script is downloaded;
        GM_get("ACFUN_BLOCK_CODE","", (s)=>{
            let currentVersion = getVersion(s);
            console.log("Current Version = "+currentVersion);
            //如果已经有可用版本,先使用
            if (currentVersion>0 && !dev){
                   var code = s;

                   setTimeout(()=>{
                                eval(code);
                   })
            }
            //检查更新
            downloadScript(
                (s)=>{
                    if (typeof s === "undefined" || s==null || s==="undefined") {
                        console.log("ACFUN屏蔽计划载入失败,请不要联系A站插件作者:人文情怀。")
                    }
                    let onlineVersion = getVersion(s);
                    console.log("online Version = "+onlineVersion);
                    //如果有更新
                    if (onlineVersion> currentVersion || dev){
                        //Update code
                        GM_set("ACFUN_BLOCK_CODE", s, ()=>{
                            //Updated, if this is the firsttime running:
                            if (currentVersion==0 || dev){
                                //如果没有可用版本,直接运行
                                console.log("直接运行");
                               setTimeout(()=>{
                                eval(s);
                              })
                            }
                        }, ()=>{
                            console.log("ACFUN屏蔽计划缓存代码失败。请不要联系作者。");
                        })
                    }
                })
        })
    }
    function debug(){
         GM_set("ACFUN_BLOCK_CODE", "", ()=>{})
    }
    //debug();
    Initialise();
})();