蓝奏云自动下载

蓝奏云跳过手动验证并自动下载, 可配置自动关闭页面

当前为 2020-10-12 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         LANZOU Auto Download
// @name:zh-CN   蓝奏云自动下载
// @namespace    lanzouyun_auto_download
// @version      2.0
// @description  蓝奏云跳过手动验证并自动下载, 可配置自动关闭页面
// @description:zh-CN  蓝奏云跳过手动验证并自动下载, 可配置自动关闭页面
// @author       Xavier Wong
// @match        *.baidupan.com/file/*
// @grant    GM_getValue
// @grant    GM_setValue
// ==/UserScript==

(
    function() {
        var defaultClose = false;
        var defaultTimeout = 1;
        var closeInterval,closeTimeout;
        'use strict';

        document.getElementById("load2").style.display="none";
        //添加倒计时显示
        var count = 2;
        var countDown = setInterval(function(){
            document.getElementById("sub").firstElementChild.innerHTML = "验证并下载 ("+ count.toFixed(1) +"s)";
            count=count-0.1;
        }, 100);
        //倒计时两秒后自动点击验证,自动点击下载
        setTimeout(function(){
            clearInterval(countDown);
            down_r(2);
            setTimeout(function(){
                window.location.href = document.getElementById("go").firstElementChild.href;
                //设置自动关闭下载页面
                closePage();
            }, 500);
        }, 2000);

        //页面关闭倒计时
        var closePage = function(){
            if(GM_getValue('doClose', defaultClose)){
                let count = GM_getValue('doCloseTimeout', defaultTimeout) * 1;
                closeInterval = setInterval(function(){
                    document.getElementById("countdown").innerHTML = "("+ count.toFixed(1) +"s)";
                    count=count-0.1;
                }, 100);
                closeTimeout = setTimeout(function(){
                    window.close();
                }, GM_getValue('doCloseTimeout', defaultTimeout) * 1000);
            }
        }

        //配置是否关闭页面
        var autoClosed = function(){
            if(GM_getValue('doClose', defaultClose) === false){
                GM_setValue('doClose', true);
            } else{
                document.getElementById("countdown").innerHTML = "";
                clearInterval(closeInterval)
                clearTimeout(closeTimeout)
                GM_setValue('doClose', false);
            }
        }
        //配置关闭页面时间
        var closeTimeoutChange = function(){
            if(!document.getElementById("closeTimeout").value || document.getElementById("closeTimeout").value < 1){
                document.getElementById("closeTimeout").value = 1;
            }
            GM_setValue('doCloseTimeout', document.getElementById("closeTimeout").value);
        }

        //添加是否关闭页面设置以及倒计时设置
        var gmSetting = document.createElement('div');
        gmSetting.style.position = 'fixed';
        gmSetting.style.top = '5%';
        gmSetting.style.right = '5%';
        gmSetting.innerHTML = '<input id="gmSetting" type="checkbox" name="gm" '+ (GM_getValue('doClose', defaultClose) ? 'checked' : '') +'/> 启动下载<input style="border:none;border-bottom:1px solid;width:50px;text-align:center" id="closeTimeout"/>秒后自动关闭页面<span id="countdown"></span>'
        document.getElementsByTagName("body")[0].append(gmSetting)
        document.getElementById("gmSetting").onclick = autoClosed;
        document.getElementById("closeTimeout").value = GM_getValue('doCloseTimeout', defaultTimeout);
        document.getElementById("closeTimeout").onchange = closeTimeoutChange;
        document.getElementById("go").onclick = closePage;
    }
)();