360,百度网盘链接

360,百度网盘链接自动添加访问密码

当前为 2015-10-07 提交的版本,查看 最新版本

// ==UserScript==
// @name        360,百度网盘链接
// @author      林岑影
// @description 360,百度网盘链接自动添加访问密码
// @namespace   
// @icon        http://disk.yun.uc.cn/favicon.ico
// @license     GPL version 3
// @encoding    utf-8
// @date        18/07/2015
// @modified    18/07/2015
// @include     *
// @exclude     http://pan.baidu.com/*
// @exclude     http://yunpan.360.cn/*
// @exclude     http://yunpan.cn/*
// @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
// ==/UserScript==

(function(window, $){
    var autoHash = function(){

    };
    autoHash.prototype = {
        init: function(){
            $("body").on("click", 'a[href*="pan.baidu.com/s/"], a[href*="yunpan.cn"]', this.replace);
        },
        replace: function(){
            var href = $(this).attr("href");
            if (href.indexOf("#")>-1) return true;
            var text = $(this).parent().text(),
                re = /(码|问)[\s|:|:]*([a-zA-Z0-9]{4,4})/g,
                r = re.exec(text);
            if (r && r[2]) {
                $(this).attr("href", href+"#"+r[2]);
            }
        }
    };
    var hash = new autoHash();
    hash.init();
}(window, jQuery))