Greasy Fork is available in English.

【懒盘-新版】百度网盘、蓝奏网盘自动填取提取码,自动激活网盘不能点击的链接

【懒盘|全新重构代码|速度更快】百度网盘,蓝奏网盘自动填取提取码。Discuz论坛、吾爱论坛,百度云、蓝奏云、百度网盘、蓝奏网盘链接激活,自动填写提取码。抓取前一页面的提取码,或从服务器获取该网盘的提取码并尝试自动填写密码和跳转。自动激活页面网盘链接,不用手动复制访问。

// ==UserScript==
// @name         【懒盘-新版】百度网盘、蓝奏网盘自动填取提取码,自动激活网盘不能点击的链接
// @namespace    https://www.lzpan.com/v2
// @version      1.2.4
// @description  【懒盘|全新重构代码|速度更快】百度网盘,蓝奏网盘自动填取提取码。Discuz论坛、吾爱论坛,百度云、蓝奏云、百度网盘、蓝奏网盘链接激活,自动填写提取码。抓取前一页面的提取码,或从服务器获取该网盘的提取码并尝试自动填写密码和跳转。自动激活页面网盘链接,不用手动复制访问。
// @author       无道
// 支持的网盘
// @include			http*://pan.baidu.com/s/*
// @include			http*://pan.lanzou.com/*
// @include         http*://www.lanzous.com/*
// @include         http://*
// @include			https://*
// 白名单
// @exclude			http*://*.pcs.baidu.com/*
// @exclude			http*://*.baidupcs.com/*
// @exclude			http*://*:8666/file/*
// @exclude			http*://index.baidu.com/*
// @exclude			http*://*.pcs.baidu.com/*
// @exclude			http*://*.baidupcs.com/*
// @exclude			http*://*:8666/file/*
// @exclude			http*://index.baidu.com/*
// @exclude			http*://*.gov/*
// @exclude			http*://*.gov.cn/*
// @exclude			http*://*.taobao.com/*
// @exclude			http*://*.tmall.com/*
// @exclude			http*://*.alimama.com/*
// @exclude			http*://*.jd.com/*
// @exclude			http*://*.zol.com.cn/*
// @exclude			http*://*.ctrip.com/*
// @exclude			http*://*.evernote.com/*
// @exclude			http*://*.yinxiang.com/*
// @exclude			http*://*.gov/*
// @exclude			http*://*.gov.cn/*
// @exclude			http*://*.taobao.com/*
// @exclude			http*://*.tmall.com/*
// @exclude			http*://*.alimama.com/*
// @match           http://*/*
// @require			http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
// @grant           unsafeWindow
// @note            2020年3月18日11:05:06 1、修复一些小错误;2、当百度云提取码页面检测到用户输入密码且提示错误后,会尝试从服务器获取密码!
// @note            2020年3月05日19:57:37 优化某些网站页面不能匹配到提取码【提取码在链接前面的情况(现在能比以前好一点了)】
// @note            2020年2月21日18:12:30 更换服务器域名,修改一些小bug
// @note            2020年2月17日12:51:59 优化代码,现在能更好的匹配单个页面中的多个分享链接的密码。
// @note            2020年2月14日17:21:09 修复一些小问题!
// @note            2020年2月12日14:41:42 全新重构版本发布!
// @grant           GM_setValue
// @grant           GM_getValue
// @grant           GM_log
// @grant           GM_deleteValue
// @grant           GM_listValues
// @grant           GM_xmlhttpRequest
// @grant           GM_info


// @icon            https://www.lzpan.com/apple-touch-icon.png
// ==/UserScript==


(function (t) {
    var i = {};

    function __webpack_require__(e) {
        if (i[e]) {
            return i[e].exports
        }
        var n = i[e] = {
            i: e,
            l: false,
            exports: {}
        };
        t[e].call(n.exports, n, n.exports, __webpack_require__);
        n.l = true;
        return n.exports
    }
    __webpack_require__.m = t;
    __webpack_require__.c = i;
    __webpack_require__.d = function (e, n, t) {
        if (!__webpack_require__.o(e, n)) {
            Object.defineProperty(e, n, {
                enumerable: true,
                get: t
            })
        }
    };
    __webpack_require__.r = function (e) {
        if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
            Object.defineProperty(e, Symbol.toStringTag, {
                value: "Module"
            })
        }
        Object.defineProperty(e, "__esModule", {
            value: true
        })
    };
    __webpack_require__.t = function (n, e) {
        if (e & 1) n = __webpack_require__(n);
        if (e & 8) return n;
        if (e & 4 && typeof n === "object" && n && n.__esModule) return n;
        var t = Object.create(null);
        __webpack_require__.r(t);
        Object.defineProperty(t, "default", {
            enumerable: true,
            value: n
        });
        if (e & 2 && typeof n != "string") for (var i in n) __webpack_require__.d(t, i, function (e) {
            return n[e]
        }.bind(null, i));
        return t
    };
    __webpack_require__.n = function (e) {
        var n = e && e.__esModule ?
            function getDefault() {
                return e["default"]
            } : function getModuleExports() {
                return e
            };
        __webpack_require__.d(n, "a", n);
        return n
    };
    __webpack_require__.o = function (e, n) {
        return Object.prototype.hasOwnProperty.call(e, n)
    };
    __webpack_require__.p = "";
    return __webpack_require__(__webpack_require__.s = 1)
})([function (e, n) {
    var l = {
        info_start: "懒盘:",
        api_server: "http://api1.lzpan.com/api"
    },
        d = {
            baidu: /(被取消了|分享文件已过期|已经被删除|分享内容可能因为|啊哦,你来晚了|取消分享了)/gi,
            lanzou: /(被取消了|分享文件已过期|已经被删除|分享内容可能因为|啊哦,你来晚了|取消分享了)/gi
        },
        t = [/password[:: ]?([^\n]+)/gim, /解压[:: ]?(\w+)/gm, /【解压密码】\s*[:: ]?\s*([^\n]+)/gim, /\[解压密码\]\s*[:: ]?\s*([a-z\d\.:/@]+)/gim, /(?:解[压壓]密?[码碼])\s*[:: ]?\s*([a-z\d\.:/@]+)/gim, /(?:解[压壓]密?[码碼])(?:都?是|为)?\s*[:: ]?\s*([\w\.:/@]+)[^$\r\n]/gim, /(?:[解激][活压壓]密?[码碼])(?:都?是|为)?\s*[:: ]?\s*([^\w]+)[^$\r\n]/gim, /【?压缩密码】?\s*[:: ]?\s*([^\n]+)/gim, /【?[資资]源密[码碼]】?:(\w+)/];
    var a = [];

    function compute_info() {
        var e = location.href;
        var n = location.hash;
        var t = location.hostname.replace(/^www\./i, "").toLowerCase();
        var i = {};
        i.href = e;
        i.hash = n;
        i.host = t;
        return i
    }
    function element_info() {
        return {
            input_aim_el: {
                baidu: "form input",
                eyun_pwd: "input.share-access-code",
                lanzou: "#pwd",
                lanzou2: "#pwd"
            },
            notice_aim_el: {
                baidu: "form",
                eyun_pwd: "p.share-access-tip",
                lanzou: "#info",
                lanzou2: "#pwderr"
            },
            click_aim_el: {
                baidu: ".input-area > div > a > span",
                eyun_pwd: ".share-access a",
                lanzou: "#passwddiv > div > div.passwddiv-input > div",
                lanzou2: "#sub"
            }
        }
    }
    function get_disk_id(e) {
        var n;
        n = /https?:\/\/(?:pan|eyun)\.baidu\.com\/share\/init\?surl=([a-zA-Z0-9_\-]{5,25})/gi.exec(e);
        if (n && n.length === 2) {
            return n[1]
        }
        n = /https?:\/\/(?:pan|eyun)\.baidu\.com\/s\/[\d]([a-zA-Z0-9_\-]{5,25})/gi.exec(e);
        if (n && n.length === 2) {
            return n[1]
        }
        n = /https?:\/\/(?:www|pan)?\.lanzous?\.com\/([\w-_]{6,10})/gi.exec(e);
        if (n && n.length === 2) {
            return n[1]
        }
        return null
    }
    function check_host() {
        var e = compute_info();
        var n = {
            lanzou: /(www|pan)?\.?lanzous?\.com\/.*/gim,
            baidu_pwd: /(pan|yun)\.baidu\.com\/share\/init\?surl/gi,
            baidu: /(pan|yun)\.baidu\.com\/s\/.*/gim,
            eyun_pwd: /eyun\.baidu\.com\/enterprise\/share\/init/gim
        };
        if (n.baidu_pwd.test(e.href)) {
            return "baidu_pwd"
        } else if (n.baidu.test(e.href)) {
            return "baidu"
        } else if (n.lanzou.test(e.href)) {
            return "lanzou"
        } else if (n.eyun_pwd.test(e.href)) {
            return "eyun_pwd"
        }
        return "other"
    }
    function get_pass(e, n, t, i) {
        if (!e) return;
        var a = GM_getValue(e + n);
        if (a) {
            t(a)
        } else {
            get_pass_from_server(e, n, t, i)
        }
    }
    function get_pass_from_server(e, n, t, i) {
        var a = l.api_server + "/pass/get";
        var r = "disk_id=" + e + "&disk_type=" + n;
        var o = "post";
        send_info(a, o, r, t, i)
    }
    function send_pass(e, n, t, i) {
        if (!e) return;
        if (!e || e === "undefined" || e === "") {
            return
        }
        var a = GM_getValue(e + n);
        if (a === undefined || a === "undefined") {
            a = ""
        }
        if (n === "BDY" && a.length !== 4) {
            a = ""
        }
        var r = GM_getValue(e + "PASS");
        if (r === undefined || r === "undefined") {
            r = ""
        }
        var o = l.api_server + "/pass/send";
        var u = "disk_id=" + e + "&disk_type=" + n + "&disk_state=1" + "&disk_pass=" + a + "&file_pass=" + r;
        var s = "post";
        send_info(o, s, u, t, i)
    }
    function send_invalidate(e, n) {
        if (!e) return;
        var t = l.api_server + "/pass/send";
        var i = "disk_state=0&disk_id=" + e + "&disk_type=" + n;
        var a = "post";
        send_info(t, a, i, null, null)
    }
    function send_info(e) {
        var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "GET";
        var t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
        var i = arguments.length > 3 ? arguments[3] : undefined;
        var a = arguments.length > 4 ? arguments[4] : undefined;
        GM_xmlhttpRequest({
            url: e,
            synchronous: false,
            method: n.toUpperCase(),
            data: t,
            headers: {
                "Content-type": "application/x-www-form-urlencoded"
            },
            onload: function onload(e) {
                e = JSON.parse(e.response);
                if (e) {
                    var n = e.msg || "";
                    if (n && a !== null) {
                        a()
                    } else {
                        i !== null ? i(e.diskPass) : ""
                    }
                } else {
                    a !== null ? a() : ""
                }
            }
        })
    }
    function unique(e) {
        for (var n = 0; n < e.length; n++) {
            for (var t = n + 1; t < e.length; t++) {
                if (e[n] === e[t]) {
                    e.splice(t, 1);
                    t--
                }
            }
        }
        return e
    }
    function get_compress_pass() {
        var e = /[【\[激活解压壓提取密码碼::\]】]{3,}\s*([\w+\.\-\~]+)/gi;
        var n = document.body.innerText.match(e);
        var t = [];
        if (!n) return "";
        for (var i = 0; i < n.length; i++) {
            t.push(n[i]);
            a.push(n[i])
        }
        t = unique(t);
        return t.join("~~")
    }
    function do_baidu() {
        var e = compute_info();
        var n = document.referrer;
        var t = get_disk_id(e.href);
        if (n.indexOf("init") > 1) {
            var i = GM_getValue(t + "BDY");
            if (i) {
                send_pass(t, "BDY", null, null)
            }
        } else {
            send_pass(t, "BDY", null, null)
        }
        var a = document.body.innerText;
        if (d.baidu.test(a)) {
            console.log("BDY---\x3e>>检测到失效页面.....");
            send_invalidate(t, "BDY")
        }
    }
    function do_baidu_pwd() {
        var e = compute_info();
        var t = get_disk_id(e.href);
        console.log("BDY----\x3e>>>disk_id:", t);
        var n = null;
        var i = null;
        var a = null;
        var r = element_info();
        n = $(r.input_aim_el.baidu);
        i = $(r.click_aim_el.baidu);
        a = $(r.notice_aim_el.baidu);
        var o = null;
        get_pass(t, "BDY", function (e) {
            n.val(e);
            a.siblings("div").show().text(l.info_start + "已找到密码,尝试输入。");
            i.click()
        }, function () {
            a.siblings("div").show().text(l.info_start + "未找到密码,请输入")
        });
        n.on("input", function (e) {
            var n = e.target.value.replace("*", "").trim();
            GM_setValue(t + "BDY", n)
        });
        o = setInterval(function () {
            console.log(a.siblings("div").show().text());
            if (/提取码错误/gi.test(a.siblings("div").show().text())) {
                a.siblings("div").show().text("检测到提取码错误,正在尝试从服务器获取");
                clearInterval(o);
                get_pass_from_server(t, "BDY", function (e) {
                    n.val(e);
                    a.siblings("div").show().text(l.info_start + "已找到密码,尝试输入。");
                    i.click()
                }, function () {
                    a.siblings("div").show().text(l.info_start + "服务器也未找到密码,请输入")
                })
            }
        }, 1e3)
    }
    function is_lanzou_pass(e, n) {
        if (e.length !== 0 && e.css("display") !== "none") return 1;
        if (n.length !== 0 && n.css("display") !== "none") return 2;
        return 0
    }
    function do_lanzou() {
        var e = compute_info();
        var t = get_disk_id(e.href);
        console.log("LZY----\x3e>>>disk_id:", t);
        var n = element_info();
        var i = $("#passwddiv");
        var a = $("#pwdload");
        var r = null;
        var o = null;
        var u = null;
        var s = is_lanzou_pass(i, a);
        if (s !== 0) {
            if (s === 1) {
                r = $(n.input_aim_el.lanzou);
                o = $(n.click_aim_el.lanzou);
                u = $(n.notice_aim_el.lanzou)
            } else {
                r = $(n.input_aim_el.lanzou2);
                o = $(n.click_aim_el.lanzou2);
                u = $(n.notice_aim_el.lanzou2)
            }
            get_pass(t, "LZY", function (e) {
                u.show().text(l.info_start + "已找到密码,将自动填入");
                r.val(e);
                o.click()
            }, function () {
                u.show().text(l.info_start + "未找到密码,请输入")
            });
            r.on("input", function (e) {
                var n = e.target.value.trim();
                GM_setValue(t + "LZY", n)
            });
            r.on("keyup", function (e) {
                if (e.keyCode === 13) {
                    send_pass(t, "LZY", null, null)
                }
            });
            o.on("click", function (e) {
                send_pass(t, "LZY", null, null)
            })
        } else {
            send_pass(t, "LZY", null, null)
        }
        var _ = document.body.innerText;
        if (d.lanzou.test(_)) {
            console.log("LZY---\x3e>>检测到失效页面.....");
            send_invalidate(t, "LZY")
        }
    }
    function do_eyun_pwd() {
        var e = compute_info();
        var t = get_disk_id(e.href);
        console.log("EYUN----\x3e>>>disk_id:", t);
        var n = null;
        var i = null;
        var a = null;
        var r = element_info();
        n = $(r.input_aim_el.eyun_pwd);
        i = $(r.click_aim_el.eyun_pwd);
        a = $(r.notice_aim_el.eyun_pwd);
        get_pass(t, "EYUN", function (e) {
            n.val(e);
            a.show().text(l.info_start + "已找到密码,尝试输入。");
            i.click()
        }, function () {
            a.show().text(l.info_start + "未找到密码,请输入")
        });
        n.on("input", function (e) {
            var n = e.target.value.replace("*", "").trim();
            GM_setValue(t + "EYUN", n)
        })
    }
    function do_others() {
        var l = get_compress_pass();
        document.body.addEventListener("click", function (e) {
            if (/^http/i.test(e.target.innerHTML)) return;
            var n = /(https?:\/\/(?:yun|pan|eyun).baidu.com\/s[hare]*\/[int?surl=]*[\w-_]{5,25})/gi;
            var t = /(https?:\/\/(?:www|pan|).lanzous?.com\/[\w\-_]{6,10})/gi;
            if (!/<a/gi.test(e.target.innerHTML) && e.path.length > 4) {
                if (e.target.innerText.match(n)) {
                    e.target.innerHTML = e.target.innerHTML.replace(n, '<a target="_blank" href="$1" style="text-decoration:none;border: 1px solid #e74c3c;color: #c0392b;">$1</a>')
                }
                if (e.target.innerText.match(t)) {
                    e.target.innerHTML = e.target.innerHTML.replace(t, '<a target="_blank" href="$1" style="text-decoration:none;border: 1px solid #e74c3c;color: #c0392b;">$1</a>')
                }
            }
        });
        var e = /((?:https?:\/\/)?(?:yun|pan|eyun).baidu.com\/s[hare]*\/[int?surl=]*[\w-_]{5,25})/gi;
        var n = /(href=["']?https?:\/\/(yun|pan|eyun).baidu.com\/s[hare]*\/[int?surl=]*[\w-_]{5,25})/gi;
        _active_link(e, n);
        var t = /((?:https?:\/\/)?(?:www|pan|).lanzous?.com\/[\w\-_]{6,10})/gi;
        var i = /(href=["']?https?:\/\/(www|pan).lanzous?.com\/[\w\-_]{6,10})/gi;
        _active_link(t, i);
        _analyze_links();

        function _active_link(i, a) {
            $(".t_f").each(function () {
                if ($(this).html().match(a)) return;
                var e = $(this).html().match(i);
                if (e) {
                    var n = $(this).html();
                    var t = i.exec(n);
                    if (t && t[0]) {
                        if (t[0].indexOf("http") === -1) {
                            n = n.replace(i, '<a target="_blank" href="http://$1" style="padding: 0 1px;color: rgb(232, 67, 147); text-decoration:none; border: 1px solid">$1</a>')
                        } else {
                            n = n.replace(i, '<a target="_blank" href="$1" style="padding: 0 1px;color: rgb(232, 67, 147); text-decoration:none; border: 1px solid">$1</a>')
                        }
                        $(this).html(n)
                    }
                }
            })
        }
        function _analyze_links() {
            var e = /(https?:\/\/(?:pan|yun|eyun)\.baidu\.com\/s\/[\w-_]{8,25})[&\w=]*[^\w]*(?:密码|授权码|提取码)*[::]*[^\w]*([\w]{4})*/gim;
            var n = /(https?:\/\/(?:www|pan)?\.lanzous?\.com\/[\w-_]{6,10})\/?[&\w=]*[^\w]*(?:密码|授权码|提取码)*[::]*[^\w]*([\w]{4})*/gim;
            _analyze_public(e, "BDY");
            _analyze_public(n, "LZY")
        }
        function get_p_from_compress() {
            if (a[0]) {
                var e = /(\w+)/gi.exec(a[0]);
                return e[0] || ""
            }
            return ""
        }
        function _analyze_public(e, n) {
            var t = /.*[驗證提取密碼码::"']+[^\w]*([\w]{3,})/gim;
            var i = document.body.innerText;
            var a = matchAll(i, e);
            for (var r = 0; r < a.length; r++) {
                var o = a[r];
                if (o.length === 3) {
                    var u = o[1];
                    var s = o[2] || get_p_from_compress();
                    var _ = get_disk_id(u);
                    if (l) {
                        GM_setValue(_ + "PASS", l)
                    }
                    GM_setValue(_ + n, s);
                    console.log("Find Pass:" + _ + "---\x3e>>" + s + "---\x3e>>" + n)
                }
            }
        }
        function matchAll(e, n) {
            var t = [];
            var i;
            while (i = n.exec(e)) {
                t.push(i)
            }
            return t
        }
    }
    n.compute_info = compute_info;
    n.get_disk_id = get_disk_id;
    n.check_host = check_host;
    n.do_baidu = do_baidu;
    n.do_baidu_pwd = do_baidu_pwd;
    n.do_lanzou = do_lanzou;
    n.do_others = do_others;
    n.do_eyun_pwd = do_eyun_pwd
}, function (e, n, t) {
    t(2)
}, function (e, n, t) {
    "use strict";
    t.r(n);
    var i = t(0);
    var a = t.n(i);
    var r = a.a.compute_info();
    var o = a.a.check_host();
    console.log("now page:" + o);
    switch (o) {
        case "baidu":
            a.a.do_baidu();
            break;
        case "baidu_pwd":
            a.a.do_baidu_pwd();
            break;
        case "lanzou":
            a.a.do_lanzou();
            break;
        case "eyun_pwd":
            a.a.do_eyun_pwd();
            break;
        default:
            a.a.do_others();
            break
    }
}]);