suyuan32 / 百度网盘提取助手

// ==UserScript==
// @name         百度网盘提取助手
// @namespace    https://www.zipmaster.top/
// @version      1.4
// @description  方便获取百度网盘提取码,共享大家的密码,让提取更方便.
// @author       勿忘心安
// @license Apache-2.0
// @copyright 2019, suyuan32 (https://openuserjs.org//users/suyuan32)
// @match        https://pan.baidu.com/share/*
// @match        https://pan.baidu.com/s/*
// @grant        GM_xmlhttpRequest
// @require https://code.jquery.com/jquery-2.1.4.min.js
// ==/UserScript==

(function() {
    'use strict';

    var  url = window.location.href;
    $(document).ready(function(){
        if(url.slice(22,27)=='share'){
             $('dt').append('<a class="g-button g-button-blue-large" data-button-id="b1" data-button-index="" href="javascript:;" id = "getpassbtn" title="查询密码"><span class="g-button-right"><span class="text" style="width: auto;">查询密码</span></span></a>');
             var gbtn = document.getElementById('getpassbtn');
             gbtn.addEventListener('click',function(){
                 var pass = '',i=1;
                 var start = url.indexOf('=')+1;
                 var end = url.length;
                 var code = url.slice(start,end);
                 GM_xmlhttpRequest({
                     method: "GET",
                     url: "https://www.zipmaster.top/getpandata/fcode/1"+code,
                     onload: function(data) {
                         if(data['response']=='failed'){
                             alert('暂时未收录\n www.zipmaster.top by 勿忘心安');
                             return;
                         }
                         $('input').each(function(){
                         if(i==1){
                             $(this).val(data['response']);
                         }
                         i++;
                     });
                     }
                 });
             });
            $('.g-button-right').each(function(){
                var j = 1,password;
                $(this).click(function(){
                    j=1;
                    var start = url.indexOf('=')+1;
                    var end = url.length;
                    var code = url.slice(start,end);
                    $('input').each(function(){
                    if(j==1){
                        password = $(this).val();
                    }
                    j++;
                });
                if(password.length!=4) return;
                    GM_xmlhttpRequest({
                        method: "GET",
                        url: "https://www.zipmaster.top/post_first/fcode/1"+code+'/pass/'+password,
                        onload: function(data) {
                        }
                    });
                });
            });
        }else{
            var start = 24;
            var end;
            if(url.indexOf('#')!=-1)
                end = url.indexOf('#');
            else
                end = url.length;
            var code = url.slice(start,end);
            var j = 1,fname;
           $('.file-name').each(function(){
                  if(j==1){
                     fname = $(this).attr('title');
                  }
                  j++;
            });
           GM_xmlhttpRequest({
               method: "GET",
               url: "https://www.zipmaster.top/post/fcode/"+code+'/fname/'+fname,
               onload: function(data) {
               }
           });
        }
    })
    ;

})();