// ==UserScript==
// @name 【复活版】百度网盘SVIP解析高速下载-度娘加速
// @namespace momoz
// @version 1.3
// @author momo
// @description 百度网盘SVIP解析高速下载,24小时维护100%可以用!使用IDM下载更加稳定
// @antifeature ads
// @antifeature membership
// @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 bd.shzxkq.com
// @connect dj.shzxkq.com
// @connect 127.0.0.1
// @grant GM_addStyle
// @grant GM_getResourceText
// @run-at document-idle
// @require https://lib.baomitu.com/layui/2.9.3/layui.min.js
// @resource layuiCSS https://lib.baomitu.com/layui/2.9.3/css/layui.css
// @resource myCSS https://bd.shzxkq.com/mm_baiduyun.css
// ==/UserScript==
(function () {
const layuicss = GM_getResourceText("layuiCSS");
GM_addStyle(layuicss);
const mycss = GM_getResourceText("myCSS");
GM_addStyle(mycss);
var config = {
main_url: 'https://dj.shzxkq.com',
bd_password: "asdf",
title_name: "度娘加速",
savePath: 'D:\\',
jsonrpc: 'http://localhost:6800/jsonrpc',
username: "",
}
layui.use(['layer'], async function () {
var layer = layui.layer, $ = layui.$;
await Promise.resolve(new Promise((resolve) => setTimeout(resolve, 888)));
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;border-color: #6800ff;" href="javascript:;" ><span class="g-button-right"><em class="icon icon-download" title=""></em><span class="text" style="width: auto;">' + config.title_name + '</span></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: #6800ff;border-color: #6800ff;" id="downbtn_main" class="g-button" ><span class="g-button-right"><em class="icon icon-download" ></em><span class="text" style="width: auto;">' + config.title_name + '</span></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: #6800ff;border-color: #6800ff;" id="downbtn_main" class="u-button nd-file-list-toolbar-action-item" ><i class="iconfont icon-download"></i> <span>' + config.title_name + '</span></button></div>');
}
}
$('#downbtn_share').click(function () {
my_alert("提示:请先保存到自己的网盘后,从网盘里解析!");
return false;
});
$('#downbtn_main').click(function () {
let xuanzhe_list = get_xuanzhe_list();
let xuanzhe_list2 = Object.keys(xuanzhe_list);
if (xuanzhe_list2.length == 0) {
my_alert("提示:请先选择一个文件");
return false;
} else if (xuanzhe_list2.length > 1) {
my_alert("提示:目前仅支持一个文件解析");
return false;
} else if (xuanzhe_list[xuanzhe_list2[0]].isdir == 1) {
my_alert("提示:目前不支持文件夹解析!");
return false;
}
let file_info_obj = xuanzhe_list[xuanzhe_list2[0]];
let html_code = `<style>
.borderNo_bottom {
border-top: 2px #000000 solid;
border-left: 2px #000000 solid;
border-right: 2px #000000 solid;
}
.borderNo_topANDleft {
border-right: 2px #000000 solid;
}
.Other_layui-tab-item {
border: 2px solid black;
height: 550px;
text-align: center;
}
.tab_item_content {
position: relative;
height: 500px;
width: 800px;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
.layui-this {
color: #000 !important;
}
.layui-layer-page {
border-radius: 0px !important;
}
.layui-tab-title .layui-this::after {
height: 40px !important;
;
}
.layui-this:after {
background-color: rgba(30, 24, 20, 0.45) !important;
border-bottom: 0px solid red !important;
width: 100% !important;
left: 0px !important;
}
.layui-btn{
background-color: #fb7d4b !important;
}
.layui-btn-disabled{background-color: #fbfbfb !important;}
</style>
<body>
<div class="layui-tab-content" style="padding-top:0px">
<div class="layui-tab-item layui-show">
<div class="layui-card" style="border: 2px solid black;margin-bottom: -2px;padding:10px 25px;">
<b>
<div id="server_filename" style="text-align:center;">当前文件名:</div>
</b>
<div style="text-align:center;">扫描二维码获取解析密码后,点击解析按钮</div>
<div style="text-align:center;">
<img src="https://bd.shzxkq.com/xcx.jpg" style="width:240px;height:240px;">
</div>
</div>
<div class="layui-card"
style="border-left: 2px solid black;padding:10px 25px;border-top: 0xp solid black;border-right: 2px #000000 solid;border-bottom: 2px #000 solid;">
<div>
<button class="layui-btn layui-btn-sm layui-btn-disabled style=" margin-top:
10px;background:#2196f3;" id="copy">IDM复制链接 UA填入netdisk; </button>
<button type="button" id="main_start" class="layui-btn layui-btn-sm" style="float: right;"><img
src="https://bd.shzxkq.com/ico.png" style="width: 15px; margin-left:-5px;">解析</button>
</div>
</div>
</div>
</div>
</body>`;
layer.open({
type: 1,
title: false,
closeBtn: 1,
shadeClose: true,
// shade: 0.9, // 遮罩透明度
area: ['500px', '367px'],//宽 高
content: html_code,
success: function (layero, index) {
$("#server_filename").text("当前文件名:" + file_info_obj.server_filename);
$('#main_start').click(function () {
if( localStorage.my_password && localStorage.my_password_end && new Date().getTime()< Number(localStorage.my_password_end) ){
layer.load(2, {
shade: [0.3, '#FFF'],
});
share_one_baidu();
} else {
let promptI = layer.prompt({ title: '密码已重置,请重新输入', formType: 1 }, function (value, index) {
layer.close(promptI);
//layer.msg("密码输入完成");
localStorage.my_password = value;
localStorage.my_password_end = get_endTime();
layer.load(2, { shade: [0.3, '#FFF'], });
share_one_baidu();
});
}
});
$('#copy').click(function () {
if (!$(this).hasClass('layui-btn-disabled')) {
var textarea = document.createElement('textarea');
textarea.style.position = 'fixed';
textarea.style.opacity = 0;
textarea.value = $(this).attr('down-url');
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
layer.msg('链接复制成功');
}
});
$('#pusharia').click(function () {
if (!$(this).hasClass('layui-btn-disabled')) {
var url = $(this).attr('down-url');
sendAria2(url, $('#server_filename').text().replace("当前文件名:", ""));
// sendAria2(url, file_info_obj.server_filename);
layer.msg('推送成功');
}
});
},
});
});
});
function formatBytes(a, b = 2) {
if (0 === a) return "0 Bytes";
const c = 0 > b ? 0 : b,
d = Math.floor(Math.log(a) / Math.log(1024));
return parseFloat((a / Math.pow(1024, d)).toFixed(c)) + " " + ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]
}
function formatDate(time, format = 'YY-MM-DD hh:mm:ss') {
if (time == undefined) return "--";
time = Number(time + "000");
var date = new Date(time);
var year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hour = date.getHours(),
min = date.getMinutes(),
sec = date.getSeconds();
var preArr = Array.apply(null, Array(10)).map(function (elem, index) {
return '0' + index;
});
var newTime = format.replace(/YY/g, year)
.replace(/MM/g, preArr[month] || month)
.replace(/DD/g, preArr[day] || day)
.replace(/hh/g, preArr[hour] || hour)
.replace(/mm/g, preArr[min] || min)
.replace(/ss/g, preArr[sec] || sec);
return newTime;
}
function get_endTime() {
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hours = date.getHours();
var on_30min = Number(new Date(year + "-" + month + "-" + day + " " + hours + ":30:00"));
if (new Date().getTime() < on_30min) {
result_time = on_30min;
} else {
result_time = on_30min + 30 * 60 * 1000;
}
return result_time;
}
function my_alert(text_value = "") {
layui.layer.open({
type: 1,
title: false,
closeBtn: 3,
shadeClose: true,
skin: 'yourclass',
content: `
<div style="border: 2px solid black;padding:30px 80px;word-wrap:break-word;">
${text_value}
</div>`
});
}
function sendAria2(url, out_filename) {
var Aria2_config = {
"jsonrpc": "2.0",
"method": "aria2.addUri",
"id": 1,
"params": [[url], {
"out": out_filename,
"dir": config.savePath,
"pause": "false",//是否暂停下载
"max-connection-per-server": "15",
"seed-ratio": "0",
"continue": 'true',
"user-agent": "LogStatistic"
}]
}
$.ajax({
url: config.jsonrpc,
data: JSON.stringify(Aria2_config),
type: "post",
//async: false,//false为同步
dataType: "json",
success: function (obj) {
console.log(obj)
}
});
}
function get_xuanzhe_list() {
var xuanzhe_list = {};
var xuanxiang = [];
try {
xuanxiang = require('system-core:context/context.js').instanceForSystem.list.getSelected();
} catch (e) {
xuanxiang = document.querySelector('.wp-s-core-pan').__vue__.selectedList;
}
xuanxiang.forEach(element => {
xuanzhe_list[element.fs_id] = element;
});
return xuanzhe_list;
}
function share_one_baidu() {
let xuanzhe_list = Object.keys(get_xuanzhe_list());
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;
$.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(xuanzhe_list)
},
dataType: 'json',
success: function (res) {
console.log(res)
if (res.show_msg.indexOf("禁止") > -1) {
layer.closeAll('loading');
my_alert("该文件禁止分享");
return false;
} else {
let shorturl = "";
try {
shorturl = res.link.split("/").pop();
} catch (error) {
layer.closeAll('loading');
my_alert("错误:初始化准备失败!");
return false;
}
get_down_list(shorturl, config.bd_password);
layer.closeAll('loading');
}
},
error: function (res) {
my_alert("错误:初始化准备请求访问失败");
layer.closeAll('loading');
},
})
}
function get_down_url(res) {
console.log("res",res)
Files = res.data.list[0];
fs_id = Files.fs_id;
randsk = res.data.shareinfo.seckey;
share_id = res.data.shareinfo.share_id;
uk = res.data.shareinfo.uk;
req_id = res.req_id;
surl = res.surl;
pwd = res.pwd;
// ${fs_id}&randsk=${randsk}&share_id=${share_id}&uk=${uk}`
let down_url = `${config.main_url}/api/v1/parse/parse_file?req_id=${req_id}&surl=${surl}&pwd=${pwd}&fs_id=${fs_id}&randsk=${randsk}&share_id=${share_id}&uk=${uk}&username=${config.username}`;
$.ajax({
url: down_url,
method: 'GET',
error: function (params) {
console.error(2, params);
my_alert("错误:解析请求访问失败");
layer.closeAll('loading');
},
success: function (json) {
// json = JSON.parse(params);
console.log(3, json);
if (json.code == 200) {
ddd = json.data;
console.log("待下载文件详情", ddd);
Size = formatBytes(ddd.filesize);
Time = formatDate(ddd.filectime, 'YY/MM/DD hh:mm:ss');
let downlink = ddd.dlink;
layer.closeAll('loading');
my_alert("成功:解析成功");
$('#copy').removeClass('layui-btn-disabled').attr('down-url', downlink);
$('#pusharia').removeClass('layui-btn-disabled').attr('down-url', downlink);
} else {
my_alert("失败:" + json.message);
layer.closeAll('loading');
return false;
}
}
});
// let ajax_data = {
// surl: res.dirdata.surl,
// pwd: config.bd_password,
// password: localStorage.my_password,
// username: config.username,
// fs_id: res.filedata[0].fs_id,
// timestamp: res.dirdata.timestamp,
// sign: res.dirdata.sign,
// randsk: res.dirdata.randsk,
// shareid: res.dirdata.shareid,
// uk: res.dirdata.uk
// }
// $.ajax({
// type: 'POST',
// url: config.main_url + '/api.php?m=Download',
// async: true,
// data: ajax_data,
// dataType: 'json',
// success: function (res) {
// if (res.error == 0) {
// let downlink = res.directlink;
// layer.closeAll('loading');
// my_alert("成功:解析成功");
// $('#copy').removeClass('layui-btn-disabled').attr('down-url', downlink);
// $('#pusharia').removeClass('layui-btn-disabled').attr('down-url', downlink);
// } else {
// my_alert("失败:" + res.message);
// layer.closeAll('loading');
// return false;
// }
// },
// error: function (res) {
// my_alert("错误:解析请求访问失败");
// layer.closeAll('loading');
// },
// });
}
function get_down_list(shorturl, password) {
let url = `${config.main_url}/api/public/use_parse_key?surl=${shorturl}&pwd=${password}&parse_key=${localStorage.my_password}&username=${config.username}`
$.ajax({
type: 'GET',
url: url,
async: true,
// data: ajax_data,
dataType: 'json',
success: function (res) {
console.log(res)
if (res.code == 200) {
req_id = res.data;
url = `https://dj.shzxkq.com/api/v1/parse/get_file_list?req_id=${req_id}&isroot=1`;
$.ajax({
url: url,
method: 'GET',
error: function (params) {
console.error(2, params);
},
success: function (json) {
// json = JSON.parse(params);
console.log(2, json);
if (json.code == 200) {
json['req_id'] = req_id;
json['pwd'] = password;
json['surl'] = shorturl;
get_down_url(json);
} else {
my_alert("失败:" + json.message);
}
}
})
} else {
if (res.code == 98) {
//重置密码
localStorage.my_password = "";
localStorage.my_password_end = "";
layer.closeAll('loading');
my_alert("失败:密码错误(可能密码超出有效期),请重置密码");
return false;
} else {
my_alert("失败:" + res.message);
layer.closeAll('loading');
return false;
}
}
},
error: function (res) {
my_alert("错误:初始解析请求访问失败");
layer.closeAll('loading');
},
});
}
})()