百度网盘分享

百度网盘批量分享, 每个勾勾都生成一个分享链接, 可以自定义访问密码

目前为 2015-08-13 提交的版本。查看 最新版本

// ==UserScript==
// @name        百度网盘分享
// @author      林岑影
// @website     http://www.cyxiaowu.com
// @description 百度网盘批量分享, 每个勾勾都生成一个分享链接, 可以自定义访问密码
// @namespace   
// @icon        http://disk.yun.uc.cn/favicon.ico
// @license     GPL version 3
// @encoding    utf-8
// @date        13/08/2015
// @modified    13/08/2015
// @include     http://pan.baidu.com/disk/*
// @require     http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @grant       unsafeWindow
// @grant       GM_setClipboard
// @run-at      document-end
// @version     1.1.0
// ==/UserScript==

var baidushares = function(){
    this.pass = "8888"; //密码
    this.timeout = 10000; //间隔时间 (毫秒)
    this.linktype = "ubb"; //输出链接格式:    ubb = ubb代码 | link = 链接 | html = html代码
    this.index = 0;
    this.arrId = [];
    this.arrName = [];
    this.setTime = null;
    this.btn = '<a node-type="btn-quickshare" data-key="quickshare" class="btn share-btn" style="display: inline-block;"><span class="ico"></span><span class="btn-val">快速分享</span></a>';
};
baidushares.prototype = {
    init: function(){
        var that = this;
        $('[data-key="download"]').after(that.btn);
        $('[data-key="quickshare"]').on("click", function(){
            that.arrId = [];
            that.arrName = [];
            that.index = 0;
            $(".list").children(".item-active").each(function(){
                dataid = $(this).data("id");
                dataname = $(this).find(".name").attr("title");
                that.arrId.push(dataid);
                that.arrName.push(dataname);
            });
            that.dialog();
            that.post();
        });
    },
    post: function(){
        var that = this,
            index = this.index;
        if (index >= this.arrId.length) {
            return false;
        }
        var id = this.arrId[index],
            name = this.arrName[index],
            text = "",
            request = $.ajax({
                url: "/share/set?channel=chunlei&clienttype=0&web=1&bdstoken=" + yunData.MYBDSTOKEN + "&app_id=25052",
                method: "POST",
                data: {
                    fid_list : "["+id+"]",
                    schannel: 4,
                    channel_list: "[]",
                    pwd: that.pass
                },
                dataType: "json"
            });

        request.done(function(json) {
            if (json.errno == 0) {
                if (that.linktype == "ubb") {
                    text = "[url="+json.shorturl+"]"+name+"[/url] 提取密码:"+that.pass;
                } else if (that.linktype == "html") {
                    text = "<a href='"+json.shorturl+"'>"+name+"</a> 提取密码:"+that.pass;
                } else {
                    text = json.shorturl +" 提取密码:"+that.pass;
                }
            } else {
                text = name+" 分享失败, 错误代码: "+json.errno;
            }
            var old = $("#shareresult").val();
            if (old=="") {
                old = text;
            } else {
                old = old+"\r\n"+text;
            }
            $("#shareresult").val(old);
            that.count();
            that.index++;
            that.setTime = setTimeout(function(){
                that.post();
            }, that.timeout);
        });
    },
    count: function(){
        var ok = parseInt($("#ok").text()) + 1;
        var all = parseInt($("#all").text());
        var no = all - ok;
        $("#ok").text(ok);
        $("#no").text(no);
    },
    dialog: function() {
        var that = this,
            html = "",
            w = 576,
            h = 514,
            ww = $(window).width(),
            hh = $(window).height();
        var l = (ww - w) / 2,
            t = (hh - h) / 2,
            length = this.arrId.length;
        html+='<div class="b-panel b-dialog box-shadow4 bdr-rnd-3 add-yun-device-dialog common-dialog" style="display: block; left: '+l+'px; top: '+t+'px;">';
        html+='    <div class="dlg-hd b-rlv"><span class="dlg-cnr dlg-cnr-l"></span>';
        html+='        <a href="javascript:void(0);" title="关闭" id="closeQuickShareDailog" class="dlg-cnr dlg-cnr-r"></a>';
        html+='        <h3><em></em>分享结果</h3>';
        html+='    </div>';
        html+='    <div class="dlg-bd global-clearfix __dlgBd" style="visibility: visible;">';
        html+='        <div class="add-yun-device-list">';
        html+='            <p style="margin-bottom: 10px;">共 <b id="all">'+length+'</b> 条, 已完成 <b id="ok">0</b> 条, 剩余 <b id="no">'+length+'</b> 条</p>';
        html+='            <textarea style="width:100%; height:400px;" id="shareresult"></textarea>';
        html+='        </div>';
        html+='    </div>';
        html+='</div>';
        $("body").append(html).find("#closeQuickShareDailog").click(function(){
            window.clearTimeout(that.setTime);
            $(this).parents(".b-dialog").remove();
        });
    }
};
var bs = new baidushares();
bs.init();

QingJ © 2025

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