Greasy Fork is available in English.

百度网盘SVIP解析高速下载-火箭加速🚀🚀

百度网盘SVIP解析高速下载,前端vue3+后端Java实现,欢迎交流!!

// ==UserScript==
// @name         百度网盘SVIP解析高速下载-火箭加速🚀🚀
// @namespace    http://tampermonkey.net/
// @version      2.9.7
// @description  百度网盘SVIP解析高速下载,前端vue3+后端Java实现,欢迎交流!!
// @author       You
// @match        http://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license            MIT
// @icon              https://nd-static.bdstatic.com/m-static/v20-main/home/img/icon-home-new.b4083345.png
// @match             *://pan.baidu.com/*
// @match             *://yun.baidu.com/*
// @match             *://pan.baidu.com/disk/home*
// @match             *://yun.baidu.com/disk/home*
// @match             *://pan.baidu.com/disk/main*
// @match             *://yun.baidu.com/disk/main*
// @match             *://pan.baidu.com/s/*
// @match             *://yun.baidu.com/s/*
// @match             *://pan.baidu.com/share/*
// @match             *://yun.baidu.com/share/*
// @connect           baidu.com
// @connect           aifenxiang.net.cn
// @connect           127.0.0.1
// @grant             GM_cookie
// @grant             GM_addStyle
// @grant             GM_getResourceText
// @require           https://lib.baomitu.com/layui/2.9.3/layui.min.js
// @require           https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js
// @require           https://unpkg.com/sweetalert/dist/sweetalert.min.js
// @resource          layuiCSS https://lib.baomitu.com/layui/2.9.3/css/layui.css
// ==/UserScript==

(function() {
    'use strict';
    //swal("Hello world!");
    const layuicss = GM_getResourceText("layuiCSS");
    GM_addStyle(layuicss);
     const config = {
        main_url: 'https://aifenxiang.net.cn:8081',
        //main_url: 'http://127.0.0.1:8081',
        bd_password: "1234",
        title_name: "火箭加速",
    }


    function getToken (x, y, num){
        num ??= y.length;
        let a = [],
            b = x.reduce(
                (d, t) => (y.includes(t.name) && d.push([t.name, t.value]), d),
                []
            );
        return (
            new Map(b).forEach((v, k) => {
                a.push(`${k}=${v}`);
            }),
            num > a.length ? '' : a.join('; ')
        );
    }

    layui.use(['layer'], async function () {
        var layer = layui.layer, $ = layui.$;
        var form = layui.form;
        if (location.href.startsWith("https://pan.baidu.com/s/")) {
            //分享界面加按钮
            $('.x-button-box').prepend('<a class="g-button" id="downbtn_share" style="background-color: #6800ff;color: #fff;"  href="javascript:;" ><span class="g-button-right"><em style="top:0;" class="icon icon-download" title=""></em><lable class="text" style="width: auto;">' + config.title_name + '</lable></span></a>');
        } else {
            // 其他界面加按钮
            if ($('.tcuLAu').is('*')) {
                //旧版
                $('.tcuLAu').prepend('<span class="g-dropdown-button"><a id="downbtn_main"  style=" margin-right: 10px;color: #fff;background-color: #fc5531;" id="downbtn_main" class="g-button" ><span class="g-button-right"><em style="top:0;" class="icon icon-download" ></em><lable class="text" style="width: auto;">' + config.title_name + '</lable></span></a></span>');
            } else {
                //新版
                $('.wp-s-agile-tool-bar__header.is-header-tool').prepend('<div class="wp-s-agile-tool-bar__h-group"><button style=" margin-right: 10px;color: #fff;background-color: #fc5531;" id="downbtn_main" class="u-button nd-file-list-toolbar-action-item" ><i style="top:0;" class="iconfont icon-download"></i> <lable>' + config.title_name + '</lable></button></div>');
            }
        }

        $('#downbtn_share').click(function () {
            swal({
                title: "提示",
                text: "请先保存到自己的网盘后,从网盘里解析!",
                icon: "warning",
            });
            return false;
        });
    $('#downbtn_main').click(function () {
        let select = selectList();
        let selected = Object.keys(select);
        if (selected.length == 0) {
            swal({
                text: "请先选择一个文件",
                icon: "warning",
            });
            return false;
        } else if (selected.length > 1) {
             swal({
                text: "目前仅支持单个文件解析",
                icon: "warning",
            });
            return false;
        } else if (select[selected[0]].isdir == 1) {
             swal({
                text: "目前不支持文件夹解析",
                icon: "warning",
            });
            return false;
        }

        let fileInfo = select[selected[0]];


        layer.msg('解析中', {
            icon: 6,
            time: 3000 // 3秒后自动关闭
        });

        setTimeout(()=>{
            swal({
                text: "解析失败请前往web端尝试下载:https://aifenxiang.net.cn",
                icon: "error",
            });
        },3000)
        return false;



    })
    })
    function selectList() {
        var select = {};
        var option = [];

        try {
            option = require('system-core:context/context.js').instanceForSystem.list.getSelected();
        } catch (e) {
            option = document.querySelector('.wp-s-core-pan').__vue__.selectedList;
        }
        option.forEach(element => {
            select[element.fs_id] = element;
        });
        return select;
    }

    function share_one_baidu(openLayer,code) {
        let select = Object.keys(selectList());
        let bdstoken = "";
        let data_json = {};
        try {
            data_json = $("html").html().match(/(?<=locals\.mset\()(.*?)(?=\);)/)[0];
            data_json = JSON.parse(data_json);
            config.username = data_json.username;
            bdstoken = data_json.bdstoken;
        } catch (e) {
            data_json = $("html").html().match(/(?<=window\.locals\s=\s)(.*?)(?=;)/)[0];
            data_json = JSON.parse(data_json);
            config.username = data_json.userInfo.username;
            bdstoken = data_json.userInfo.bdstoken;
        }

        config.data_json = data_json;


        const param =  {
                bdstoken: bdstoken,
                period: 1,
                pwd: config.bd_password,
                eflag_disable: true,
                channel_list: "%5B%5D",
                schannel: 4,
                fid_list: JSON.stringify(select)
            }

        $.ajax({
            type: 'GET',
            url: "https://pan.baidu.com/share/set",
            async: true,
            data: {
                bdstoken: bdstoken,
                period: 1,
                pwd: config.bd_password,
                eflag_disable: true,
                channel_list: "%5B%5D",
                schannel: 4,
                fid_list: JSON.stringify(select)
            },
            dataType: 'json',
            success: function (res) {

                if (res.show_msg.indexOf("禁止") > -1) {
                    swal({
                        text: "该文件禁止分享",
                        icon: "error",
                    });
                    return false;
                } else {
                    let shorturl = "";
                    try {
                        shorturl = res.link.split("/").pop();
                    } catch (error) {
                        swal({
                            text: "初始化准备失败",
                            icon: "error",
                        });
                        return false;
                    }

                    get_down_list(shorturl, config.bd_password,openLayer,code);


                }

            },
            error: function (res) {
                swal({
                    text: "初始化准备请求访问失败",
                    icon: "error",
                });

            },
        })

    }

    async function get_down_list(shorturl, password,openLayer,code) {

        let ajax_data = { shorturl: shorturl, pwd: password,dir : 1,root: 1 }

        fetch(config.main_url + "/wp/parseCopyLink",{
            method:"POST",
            headers:{
                "Content-Type": "application/json",
            },
            body: JSON.stringify(ajax_data),
        })
            .then(resp=>resp.json())
            .then((res)=>{
            if (res.code == 200) {
                const size = parseInt(res.data.data.list[0].size);
                if (!code.includes('svip')) {
                    if(size > 6698669056){
                        layer.close(openLayer);
                        swal({
                            text: "文件太大了,插件暂不支持下载,请联系作者开通权限!",
                            icon: "warning",
                        });
                        return false;

                    }
                 }
                const params = {
                    shareid:res.data.data.shareid,
                    from:res.data.data.uk,
                    sekey:res.data.data.seckey,
                    fsId:res.data.data.list[0].fs_id,
                    path:`/`+res.data.data.list[0].server_filename

                };

                fetch(config.main_url + "/wp/dlink",{
                    method:"POST",
                    headers:{
                        "Content-Type": "application/json",
                    },
                    body: JSON.stringify(params),
                })
                    .then(resp=>resp.json())
                    .then((data)=>{
                    if (data.code == 200) {
                        layer.close(openLayer);
                        swal({
                            text: "文件开始下载,请打开下载器查看",
                            icon: "success",
                        });
                        console.log(data);
                        const url = data.data[0].url;
                        const o = {
                            id: 'wp',
                            method: 'aria2.addUri',
                            params: [
                                [
                                    url
                                ],
                                {
                                    'user-agent':
                                    'netdisk;7.42.0.5;PC;PC-Windows;10.0.22631;WindowsBaiduYunGuanJia',
                                },
                            ],
                        };

                        fetch('http://localhost:16800/jsonrpc', {
                            method: 'POST',
                            headers: {
                                'Content-Type': 'application/json',
                            },
                            body: JSON.stringify(o),
                        })
                            .then((resp) => resp.json())
                            .then((res) => {});



                    }else{
                        layer.close(openLayer);
                        swal({
                            text: "解析遇到问题了,请刷新重试即可!!",
                            icon: "warning",
                        });

                    }
                })
                return false;


            }
        })

    }

    function get_down_url(res,shorturl,password,openLayer,size) {

        let ajax_data = {
            surl: shorturl,
            pwd: password,
            fs_id: res.data.list[0].fs_id,
            randsk: res.data.seckey,
            shareid: res.data.shareid,
            uk: res.data.uk,
            code:config.code,
        }

        const signParams = {

            shorturl:shorturl,
            shareid: res.data.shareid,
            uk: res.data.uk

        }


        fetch(config.main_url + "/wp/getSign",{
            method:"POST",
            headers:{
                "Content-Type": "application/json",
            },
            body: JSON.stringify(signParams),
        }).then(resp=>resp.json())
            .then((res)=>{

            if (res.code == 200) {
                ajax_data.sign = res.data.result.data.sign;
                ajax_data.timestamp = res.data.result.data.timestamp;
                ajax_data.index = res.data.index;
                ajax_data.uid = config.uid
                ajax_data.token = config.token
                fetch(config.main_url + "/wp/parseLink",{
                    method:"POST",
                    headers:{
                        "Content-Type": "application/json",
                    },
                    body: JSON.stringify(ajax_data),
                }).then(resp=>resp.json())
                    .then((data)=>{

                    if (data.code == 200) {
                       layer.close(openLayer);
                        if(data.data.code == 0){


                            fetch(config.main_url + "/wp/down/load/code",{
                                method:"POST",
                                headers:{
                                    "Content-Type": "application/json",
                                },
                                body: JSON.stringify({code:config.code}),
                            })

                            const o = {
                                id: 'wp',
                                method: 'aria2.addUri',
                                params: [
                                    data.data.data.url,
                                    data.data.data.info,
                                ],
                            };

                            fetch('http://localhost:16800/jsonrpc', {
                                method: 'POST',
                                headers: {
                                    'Content-Type': 'application/json',
                                },
                                body: JSON.stringify(o),
                            })
                                .then((resp) => resp.json())
                                .then((res) => {});

                            swal({
                                text: "文件开始下载,请打开下载器查看",
                                icon: "success",
                            });


                        }else{
                             swal({
                                text: "解析遇到问题了,请刷新重试即可!!",
                                icon: "warning",
                            });

                        }


                    }
                })
            }
        })

    }

    function downLoad(item){

        //发送到下载器
        let options = {
            'max-connection-per-server': '16',
            'user-agent': 'LogStatistic',
            'opt': item.server_filename.trim()
        };

        let json = {
            id: 'wp',
            jsonrpc: '2.0',
            method: 'aria2.addUri',
            params: [[item.realLink], options],
        };

        json.params.unshift('token:undefined');
        const ws = new WebSocket('ws://localhost:16800/jsonrpc');

         ws.onerror = (event) => {

             swal({
                 text: "链接失败,请检查是否安装Motrix",
                 icon: "error",
             });

            };
            ws.onopen = () => {

              ws.send(JSON.stringify(json));
            };

            ws.onmessage = (event) => {
              let received_msg = JSON.parse(event.data);
              if (received_msg.error !== undefined) {
                if (received_msg.error.code === 1) {
                    swal({
                        text: "链接失败,请检查是否安装Motrix",
                        icon: "error",
                    });
                  return;
                };
              }

              switch (received_msg.method) {
                case 'aria2.onDownloadStart':

                  break;

                case 'aria2.onDownloadError':

                      swal({
                          text: "链接失败,请检查是否安装Motrix",
                          icon: "error",
                      });
                  break;

                case 'aria2.onDownloadComplete':

                      swal({
                          text: `${item.server_filename}下载完成!`,
                          icon: "success",
                      });
                  ws.close();
                  break;
                default:
                  break;
              }
            };

    }

    function testDownLoad(){
        return new Promise(resolve =>{
            let ws = new WebSocket('ws://localhost:16800/jsonrpc');
            ws.onopen = (event) => {
                if(event.type === 'open'){
                    // console.log(event);
                    ws.close();
                    resolve(true);
                }
            };
            ws.onerror = (event) => {
                if(event.type === 'error'){
                    // console.log(event);
                    ws.close();
                    resolve(false);
                }
            };
        });
    }


    // Your code here...
})();