// ==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 15/08/2015 // @modified 15/08/2015 // @include http://pan.baidu.com/share/* // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @grant unsafeWindow // @grant GM_setClipboard // @run-at document-end // @version 1.0.0 // @downloadURL none // ==/UserScript== var getbaidushares = function(){ this.linktype = "link"; //输出链接格式: ubb = ubb代码 | link = 链接 | html = html代码 this.index = 0; this.arrUrl = []; this.arrName = []; this.setTime = null; this.btn = '获取链接'; }; getbaidushares.prototype = { init: function(){ var that = this; $('[data-key="unshare"]').after(that.btn); $('[data-key="getshare"]').on("click", function(){ that.arrId = []; that.arrName = []; that.index = 0; $('[node-type="list"]').children(".item-active").each(function(){ dataurl = $(this).find('[node-type="copy-bar"]').text(); dataname = $(this).find('[node-type="name"]').attr("title"); that.arrUrl.push(dataurl); that.arrName.push(dataname); }); that.dialog(); that.post(); }); }, post: function(){ var that = this, $return = ""; $.each(this.arrUrl, function(i, j){ j = j.replace(/[\s]+/g, " "); j = j.replace("复制", ""); j = j.replace("链接: ", ""); if (that.linktype == "ubb") { j = j.replace(/http:\/\/(.*?) /g, "[url=http://$1]百度网盘下载:"+that.arrName[i]+"[/url] "); } else if (that.linktype == "html") { j = j.replace(/http:\/\/(.*?) /g, "百度网盘下载:"+that.arrName[i]+" "); } $return = $return + j + "\r\n"; }); $("#getshareresult").val($return); }, 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+='
'; $("body").append(html).find("#closeGetShareDailog").click(function(){ $(this).parents(".b-dialog").remove(); }); } }; var geturl = new getbaidushares(); geturl.init();