Greasy Fork is available in English.

115批量文件迅雷下载(暂不支持文件夹类型下载)

迅雷党的福音来啦~\(≧▽≦)/~,免VIP,免115浏览器

11.03.2017 itibariyledir. En son verisyonu görün.

// ==UserScript==
// @name        115批量文件迅雷下载(暂不支持文件夹类型下载)
// @namespace   sscozak
// @include     http://115.com/*
// @version     1.1
// @run-at      document-end
// @grant       none
// @description 迅雷党的福音来啦~\(≧▽≦)/~,免VIP,免115浏览器
// ==/UserScript==

// URL列表数值及相关维护操作
Core.FileAPI.thunder_urls = new Array();
Core.FileAPI.thunder_table = null;
Core.FileAPI.thunderClear = function() {
    var len = this.thunder_urls.length;
    this.thunder_urls.splice(0,len);
    this.thunder_table = null;
};
// 更新窗口URL列表
Core.FileAPI.thunderUpdateTable = function(r) {
    if (this.thunder_table) {
        var row = this.thunder_table.insertRow();
        row.style["white-space"]="nowrap"; // 内容水平展开,不自动换行
        var cell = row.insertCell(); cell.align = "left"; cell.innerHTML = r.file_name;
        var cell = row.insertCell(); cell.align = "left"; cell.innerHTML = r.file_url;
    }
};
Core.FileAPI.thunderPushURL = function(url) {
    this.thunder_urls.push(url);
};
// 启动下载
Core.FileAPI.thunderLaunch = function() {
    var len = this.thunder_urls.length;
    if (0 >= len) {
        alert("URL列表为空。。");
        return;
    }
    var urls = this.thunder_urls;
    $.getScript("http://pstatic.xunlei.com/js/webThunderDetect.js");
    $.getScript("http://pstatic.xunlei.com/js/base64.js");
    $.getScript("http://pstatic.xunlei.com/js/thunderBatch.js", function() {
                    var pid = 66666;
                    BatchTasker.BeginBatch(4,pid);    //开始批量添加
                    for (var i = 0; i < len; i++) {
                        BatchTasker.AddTask(ThunderEncode(urls[i].file_url), urls[i].file_name);    //添加下载任务
                    }
                    BatchTasker.EndBatch(pid);
                });
};
// 显示下载窗口
Core.FileAPI.thunderShowPage = function() {
    var stylePatcher = function(obj, attr_nm, attr_vl) {
        for (var i = 0; i < attr_nm.length; i++) {
        obj.style[attr_nm[i]] = attr_vl[i];
    }
    };
    // 子窗口
    var url_wdw = document.createElement('div'); url_wdw.id = "ID_url_wdw";
    url_wdw.className = 'dialog-box dialog-mini easy-download window-current';
    stylePatcher(url_wdw, 
        ['z-index', 'width', 'position', 'top', 'left'],
        ['1000000002', '530px', 'fixed', '56px', '418px']);
    document.body.appendChild(url_wdw);
    // 构建列表页面
    var html = [];
    html.push('<div class="dialog-box dialog-mini easy-download window-current" style="z-index: 1000000002; '
                    +'width: 530px; position: fixed; top: 56px; left: 418px;">');
    html.push('<div class="dialog-header" rel="title_box" ws_property="1"><h3 rel="base_title">迅雷批量下载</h3></div>');
    html.push('<div class="dialog-handle"><a href="javascript:;" class="close" id="ID_thunder_close">关闭</a></div>');
    html.push('<div rel="base_content"><div class="dialog-frame" style="height:240px; overflow:scroll;">'
                +'<table id="ID_thunderTable" style="height: auto" border="1" cellspacing="20"></table>');
    html.push('</div><div><a href="javascript:;" class="button btn-green" style="width:100%; padding:unset" onclick="Core.FileAPI.thunderLaunch()">'
                    +'<i class="icon ico-normal"></i><em>开始下载</em></a></div></div></div>');
    url_wdw.innerHTML = (function(){
        var res = '';
        for (var i = 0; i < html.length; i++) {
            res += html[i];
        }
        return res;
    })();
    // 获取列表Table
    this.thunder_table = document.getElementById('ID_thunderTable');
    // 背景蒙版
    var bk_mask = document.createElement('div'); bk_mask.id = "ID_bk_mask";
    stylePatcher(bk_mask, 
        ['z-index', 'background', 'height', 'left', 'position', 'top', 'width', 'opacity'],
        ['1000000001', 'rgb(0, 0, 0)', '100%', '0px', 'fixed', '0px', '100%', '0.4']);
    document.body.appendChild(bk_mask);
    var bk_mask_inner = document.createElement('div');
    stylePatcher(bk_mask_inner,
        ['height', 'width'],
        ['100%', '100%']);
    bk_mask.appendChild(bk_mask_inner);
    // 设置关闭窗口按钮事件
    var btn_close = document.getElementById('ID_thunder_close');
    btn_close.onclick = Function('(function(){document.body.removeChild(document.getElementById("ID_bk_mask"));'
                                            +'document.body.removeChild(document.getElementById("ID_url_wdw"))})()');
};


// 替换原函数,直接根据pickcode请求资源URL
Core.FileAPI.Download = function (pick_code, win) {
    var _ = function () {
        UA$.ajax({
            url: 'files/download?pickcode=' + pick_code,
            type: 'GET',
            dataType: 'json',
            cache: false,
            success: function (r) {
                //alert("URL: "+r.file_url);
                Core.FileAPI.thunderPushURL(r);
                Core.FileAPI.thunderUpdateTable(r);
            }
        })
    };
    _();
    return;
};

// 替换原函数,对所有选中的文件(不含文件夹)进行URL获取
Core.FileAPI.DownloadSomeFile = function (list) {
    if (!list.length) {
        Core.MinMessage.Show({
            text: '请选择文件',
            type: 'war',
            timeout: 2000
        });
        return;
    }
    var check_type = function(list) {
        for (var i = 0; i < list.length; i++) {
            if (list[i].attr('file_type') != '1') {
                return false;
            }
        }
        return true;
    }
    if (check_type(list)) {
        this.thunderClear();
        this.thunderShowPage();
        for (var i = 0; i < list.length; i++) {
            Core.FileAPI.Download(list[i].attr('pick_code'));
        }
    } else {
        if ('DownFile' in Core) {
            Core.DownFile.Go(list);
            return false;
        }
    }
};