⽕狐浏览器使⽤度盘秒传
1.搜索油猴插件。
2.安装,导⼊妙传脚本。
"use strict";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (OwnPropertySymbols) { var symbols = OwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Objec function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// ==UserScript==
// @name 秒传链接提取
// @namespace nefire
// @version 1.5.4
// @description ⽤于提取和⽣成百度⽹盘秒传链接
// @author mengzonefire
// @match *://pan.baidu/disk/home*
// @match *://yun.baidu/disk/home*
// @resource sweetalert2Css cdn.jsdelivr/npm/sweetalert2@8/dist/sweetalert2.min.css
// @require cdn.jsdelivr/npm/sweetalert2@8/dist/sweetalert2.min.js
// @require cdn.jsdelivr/npm/js-base64
// @require /spark-md5/3.0.0/spark-md5.min.js
// @grant GM_setValue
// @grant GM_getValue
/
/ @grant GM_deleteValue
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// @grant GM_info
// @grant GM_getResourceText
// @grant GM_addStyle
// @run-at document-start
// @connect *
// ==/UserScript==
!function () {
'use strict';
var meta_url = 'pcs.baidu/rest/2.0/pcs/file?app_id=778750&method=meta&path=';
var info_url = 'pan.baidu/rest/2.0/xpan/nas?method=uinfo';
var api_url = 'pan.baidu/rest/2.0/xpan/multimedia?method=listall&order=name&limit=10000';
var pcs_url = 'pcs.baidu/rest/2.0/pcs/file';
var appid_list = ['266719', '265486', '250528', '778750', '498065', '309847']; //使⽤'250528', '265486', '266719', 下载50M以上的⽂件会报403, ⿊号情况下部分⽂件也会报403
var bad_md5 = ['fcadf26fc508b8039bee8f0901d9c58e', '2d9a55b7d5fe70e74ce8c3b2be8f8e43', 'b912d5b77babf959865100bf1d0c2a19'];
var css_url = {
'Minimal': 'cdn.jsdelivr/npm/sweetalert2@8/dist/sweetalert2.min.css',
'Dark': 'cdn.jsdelivr/npm/@sweetalert2/theme-dark@4/dark.css',
'WordPress Admin': 'cdn.jsdelivr/npm/@sweetalert2/theme-wordpress-admin@4/wordpress-
admin.css',
'Material UI': 'cdn.jsdelivr/npm/@sweetalert2/theme-material-ui@4/material-ui.css',
'Bulma': 'cdn.jsdelivr/npm/@sweetalert2/theme-bulma@4/bulma.css',
'Bootstrap 4': 'cdn.jsdelivr/npm/@sweetalert2/theme-bootstrap-4@4/bootstrap-4.css'
};
var select_list,
failed = 0,
vip_type = 0,
interval = 0,
check_mode = false,
interval_mode = false,
file_info_list = [],
gen_success_list = [],
dir,
file_num,
gen_num,
gen_prog,
codeInfo,
recursive,
bdcode,
xmlhttpRequest;
var myStyle = "style=\"width: 100%;height: 34px;display: block;line-height: 34px;text-align: center;\"";
var myBtnStyle = "style=\"height: 26px;line-height: 26px;vertical-align: middle;\"";
var html_btn = "<a class=\"g-button g-button-blue\" id=\"bdlink_btn\" title=\"\u79D2\u4F20\u94FE\u63A5\" style=\"display: inline-block;\"\">\n <span class=\"g-button-right\"><em class=\"icon icon-disk\" title=\"\u79D2\u4F20\u94FE\u63A5\u63 var html_btn_gen = "<a class=\"g-button gen-bdlink-button\"><span class=\"g-button-right\"><em class=\"icon icon-share\" title=\"\u751F\u6210\u79D2\u4F20\"></em><span class=\"text\">\u751F\u6210\u79D2\u4F20</span></span></a>";
var html_check_md5 = "<p ".concat(myStyle, ">\u6D4B\u8BD5\u79D2\u4F20, \u53EF\u9632\u6B62\u79D2\u4F20\u5931\u6548<a class=\"g-button g-button-blue\" id=\"check_md5_btn\" ").concat(myBtnStyle, "><span class=\"g-button-right\" ") var html_document = "<p ".concat(myStyle, ">\u5206\u4EAB\u8FC7\u7A0B\u4E2D\u9047\u5230\u95EE\u9898\u53EF\u53C2\u8003<a class=\"g-button g-button-blue\" ").concat(myBtnStyle, " href=\"shimo.im/docs/TZ1JJuEjOM0wnFDH var html_donate = "<p id=\"bdcode_donate\" ".concat(myStyle, ">\u82E5\u559C\u6B22\u8BE5\u811A\u672C, \u53EF\u524D\u5F80 <a href=\"afdian/@mengzonefire\" rel=\"noopener noreferrer\" target=\"_blank\">\u8D5E\u52A9\
u987 var html_feedback = "<p id=\"bdcode_feedback\" ".concat(myStyle, ">\u82E5\u6709\u4EFB\u4F55\u7591\u95EE, \u53EF\u524D\u5F80 <a href=\"/zh-CN/scripts/397324\" rel=\"noopener noreferrer\" target=\"_blank\">\u811 var csd_hint_html = '<p>弹出跨域访问窗⼝时,请选择"总是允许"或"总是允许全部域名"</p><img src="b.bdstatic/bjh/763ff5014cca49237cb3ede92b5b7ac5.png">';
var checkbox_par = {
input: 'checkbox',
inputValue: GM_getValue('with_path'),
inputPlaceholder: '导出⽂件夹⽬录结构'
};
var show_prog = function show_prog(r) {
Content = "".concat(parseInt(r.loaded / r.total * 100), "%");
};
if (dString) {
}
function add_file_list(file_list) {
var dir_list = [];
file_list.forEach(function (item) {
if (item.isdir) {
dir_list.push(item.path);
} else {
file_info_list.push({
'path': item.path,
'size': item.size
});
}
});
if (dir_list.length) {
Swal.fire({
type: 'info',
title: '选择中包含⽂件夹, 是否递归⽣成?',
text: '若选是, 将同时⽣成各级⼦⽂件夹下的⽂件',
allowOutsideClick: false,
focusCancel: true,
showCancelButton: true,
reverseButtons: true,
showCloseButton: true,
confirmButtonText: '是',
cancelButtonText: '否'
recursive = true;
} else if (result.dismiss === Swal.DismissReason.cancel) {
recursive = false;
} else {
return;
}
add_dir_list(dir_list);
});
} else {
Gen_bdlink();
}
}
function add_dir_list(dir_list) {
var dir_id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
if (dir_id >= dir_list.length) {
Gen_bdlink();
return;
}
var path = dir_list[dir_id];
var list_dir_par = {
url: api_url + "&path=".concat(encodeURIComponent(path), "&recursion=").concat(recursive ? 1 : 0), type: 'GET',
responseType: 'json',
onload: function onload(r) {
if (parseInt(r.status / 100) === 2) {
if (!) {
item.isdir || file_info_list.push({
'path': item.path,
'size': item.size
});
});
} else {
file_info_list.push({
'path': path,
'errno': 810
});
}
} else {
file_info_list.push({
'path': path,
'errno': r.status
});
}
add_dir_list(dir_list, dir_id + 1);
},
onerror: function onerror(r) {
file_info_list.push({
'path': path,
'errno': 514
});
add_dir_list(dir_list, dir_id + 1);
}
};
GM_xmlhttpRequest(list_dir_par);
}
function initButtonEvent() {
$(document).on('click', '.gen-bdlink-button', function () {
if (!GM_getValue('gen_no_first')) {
Swal.fire({
title: '⾸次使⽤请注意',
showCloseButton: true,
allowOutsideClick: false,
html: csd_hint_html
}).then(function (result) {
if (result.value) {
GM_setValue('gen_no_first', true);
select_list = getSelectedFileList();
add_file_list(select_list);
}
});
return;
}
if (GM_getValue('unfinish')) {
Swal.fire({
title: '检测到未完成的秒传任务',
text: '是否继续进⾏?',
showCancelButton: true,
allowOutsideClick: false,
confirmButtonText: '确定',
cancelButtonText: '取消'
}).then(function (result) {
if (result.value) {
var unfinish_info = GM_getValue('unfinish');
file_info_list = unfinish_info.file_info_list;
Gen_bdlink(unfinish_info.file_id);
} else {
GM_deleteValue('unfinish');
select_list = getSelectedFileList();
add_file_list(select_list);
}
});
} else {
select_list = getSelectedFileList();
add_file_list(select_list);
}
});
}
function getSelectedFileList() {
quire('system-core:context/context.js').Selected(); }
;
function initButtonHome() {
var loop = setInterval(function () {
var html_tag = $('uLAu');
if (!html_tag.length) return false;
if (!$('#h5Input0').length) return false;
html_tag.append(html_btn);
var loop2 = setInterval(function () {
var btn_tag = $('#bdlink_btn');
if (!btn_tag.length) return false;
clearInterval(loop2);
}, 50);
clearInterval(loop);
}, 50);
}
function initButtonGen() {
var listTools = getSystemContext().ButtonBroker('listTools');
if (listTools && listTools.$box) {
$(listTools.$box).children('div').after(html_btn_gen);
initButtonEvent();
} else {
setTimeout(initButtonGen, 500);
}
}
;
function getSystemContext() {
quire('system-core:context/context.js').instanceForSystem;
}
;
function Gen_bdlink() {
var file_id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;贾静雯的女儿
if (file_info_list.length > 10 && vip_type === 2 && !interval_mode) {
Set_interval(file_id);
return;
}
Swal.fire({
title: '秒传⽣成中',
showCloseButton: true,
allowOutsideClick: false,
html: '<p>正在⽣成第 <gen_num></gen_num> 个</p><p><gen_prog></gen_prog></p>',
onBeforeOpen: function onBeforeOpen() {
Swal.showLoading();
var content = Content();
if (content) {
gen_num = content.querySelector('gen_num');
gen_prog = content.querySelector('gen_prog');
myGenerater(file_id);
}
}
}).then(function (result) {
if (result.dismiss && xmlhttpRequest) {
xmlhttpRequest.abort();
GM_deleteValue('unfinish');
interval_mode = false;
file_info_list = [];
}
});
}
function Set_interval(file_id) {
var test_par = /\d+/;
interval = GM_getValue('interval') || 15;
Swal.fire({
title: '批量⽣成注意',
text: '检测到超会账号且⽣成的⽂件较多, 会因为⽣成过快导致接⼝被限制(#403), 请输⼊⽣成间隔(1-30秒,推荐15)防⽌上述情况', input: 'text',
inputValue: interval,
showCancelButton: false,
allowOutsideClick: false,
confirmButtonText: '确定',
inputValidator: function inputValidator(value) {
if (!value) {
return '不能为空';
}
if (!st(value)) {
return '输⼊格式不正确, 请输⼊数字';
}
if (Number(value) > 30 || Number(value) < 1) {
return '输⼊应在1-30之间';
}
}
}).then(function (result) {
interval = Number(result.value);
GM_setValue('interval', interval);
interval_mode = true;
Gen_bdlink(file_id);
});
}
var show_prog = function show_prog(r) {
Content = "".concat(parseInt(r.loaded / r.total * 100), "%");
};
function test_bdlink() {
if (!GM_getValue('show_test_warning')) {
Swal.fire({
title: '注意',
text: '测试秒传会转存并覆盖⽂件,若在⽣成期间修改过同名⽂件,为避免修改的⽂件丢失,请不要使⽤此功能!',
input: 'checkbox',
inputPlaceholder: '不再显⽰',
showCancelButton: true,
allowOutsideClick: false,
confirmButtonText: '确定',
cancelButtonText: '返回'
}).then(function (result) {
GM_setValue('show_test_warning', result.value);
if (!result.dismiss) {
codeInfo = gen_success_list;
check_mode = true;
Process();
} else {
gen_success_list = [];
myGenerater(file_info_list.length);
}
});
} else {
codeInfo = gen_success_list;
check_mode = true;
function myGenerater(file_id) {
var appid_id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var failed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
GM_setValue('unfinish', {
'file_info_list': file_info_list,
'file_id': file_id
});
if (file_id >= file_info_list.length) {
bdcode = '';
var failed_info = '';
var gen_failed = 0;
file_info_list.forEach(function (item) {
if (item.hasOwnProperty('errno')) {
gen_failed++;
failed_info += "<p>\u6587\u4EF6\uFF1A".concat(item.path, "</p><p>\u5931\u8D25\u539F\u56E0\uFF1A").concat(, item.size), "(#")., ")</p>"); } else {
gen_success_list.push(item);
bdcode += "".concat(item.md5, "#").concat(item.md5s, "#").concat(item.size, "#").concat(item.path, "\n");
}
});
bdcode = im();
if (failed_info) {
failed_info = '<p>失败⽂件列表:</p>' + failed_info;
}
Swal.fire(_objectSpread(_objectSpread({
title: "\u751F\u6210\u5B8C\u6BD5 \u5171".concat(file_info_list.length, "\u4E2A, \u5931\u8D25").concat(gen_failed, "\u4E2A!"),
confirmButtonText: '复制秒传代码',
cancelButtonText: '取消',
showCloseButton: true,
showCancelButton: !bdcode,
showConfirmButton: bdcode,
allowOutsideClick: false,
html: bdcode ? html_check_md5 + html_document + (failed_info && '<p><br></p>' + failed_info) : html_document + '<p><br></p>' + failed_info
}, bdcode && checkbox_par), {}, {
onBeforeOpen: function onBeforeOpen() {
var loop = setInterval(function () {
var html_tag = $('#check_md5_btn');
if (!html_tag.length) return false;
$('#check_md5_btn').click(function () {
test_bdlink();
});
clearInterval(loop);
}, 50);
Add_ateElement('div'));
}
})).then(function (result) {
if (!result.dismiss) {
if (!result.value) {
bdcode = place(/(\/.+\/)|(\/)/g, '');
}
checkbox_par.inputValue = result.value;
GM_setValue('with_path', result.value);
GM_setClipboard(bdcode);
}
file_info_list = [];
gen_success_list = [];
GM_deleteValue('unfinish');
interval_mode = false;
});
return;
}
var file_info = file_info_list[file_id];
if (file_info.hasOwnProperty('errno')) {
myGenerater(file_id + 1);
return;
}
if (file_info.size > 21474836480) {
= 3939;
myGenerater(file_id + 1);
return;
}
var path = file_info.path;
Content = (file_id + 1).toString() + ' / ' + file_info_String();
Content = '0%';
var dl_size = file_info.size < 262144 ? file_info.size - 1 : 262143;
if (!failed) {
appid_id = file_info.size < 50000000 ? 0 : 3;
}
var get_dl_par = {
url: pcs_url + "?app_id=".concat(appid_list[appid_id], "&method=download&path=").concat(encodeURIComponent(path)),
type: 'GET',
headers: {
'Range': "bytes=0-".concat(dl_size)
},
responseType: 'arraybuffer',
onprogress: show_prog,
ontimeout: function ontimeout(r) {
myGenerater(file_id);
console.log('timeout ');
},
onerror: function onerror(r) {
= 514;
myGenerater(file_id + 1);
},
onload: function onload(r) {
if (parseInt(r.status / 100) === 2) {
var responseHeaders = r.responseHeaders;
var file_md5 = responseHeaders.match(/content-md5: ([\da-f]{32})/i);
if (file_md5) {
file_md5 = file_md5[1].toLowerCase();
} else {
try_get_md5(file_id, r.response);
return;
} //bad_md5内的三个md5是和谐⽂件返回的, 第⼀个是txt格式的"温馨提⽰.txt", 第⼆个是视频格式的(俗称5s),第三个为新发现的8s视频⽂件
if (bad_md5.indexOf(file_md5) !== -1 || r.finalUrl.indexOf('issuecdn.baidupcs') !== -1) {
var spark = new SparkMD5.ArrayBuffer();
spark.sponse);
var slice_md5 = d();
file_info.md5 = file_md5;
file_info.md5s = slice_md5;
}
Content = '100%';
setTimeout(function () {
myGenerater(file_id + 1);
}, interval_mode ? interval * 1000 : 1000);
} else {
console.log("return #403, appid: ".concat(appid_list[appid_id]));
if (r.status == 403 && appid_id < appid_list.length - 1) {
myGenerater(file_id, appid_id + 1, true);
} else {
= r.status;
myGenerater(file_id + 1);
}
}
}
};
xmlhttpRequest = GM_xmlhttpRequest(get_dl_par);
}
function try_get_md5(file_id, file_date) {
var file_info = file_info_list[file_id];
var get_dl_par = {
url: meta_url + encodeURIComponent(file_info.path),
type: 'GET',
onload: function onload(r) {
var file_md5 = r.responseText.match(/"block_list":\["([\da-f]{32})"\]/i) || r.responseText.match(/md5":"([\da-f]{32})"/i); if (file_md5) {
file_info.md5 = file_md5[1].toLowerCase();
var spark = new SparkMD5.ArrayBuffer();
spark.append(file_date);
file_info.md5s = d();
} else {
= 996;
}
myGenerater(file_id + 1);
}
};
GM_xmlhttpRequest(get_dl_par);
}
/**
* ⼀个简单的类似于 NodeJS Buffer 的实现.
* ⽤于解析游侠度娘提取码。
* @param {SimpleBuffer}
*/
function SimpleBuffer(str) {
this.fromString(str);
}
return ('0' + n.toString(16)).slice(-2);
};
SimpleBuffer.prototype.fromString = function fromString(str) {
var len = str.length;
this.buf = new Uint8Array(len);
for (var i = 0; i < len; i++) {
this.buf[i] = str.charCodeAt(i);
}
};
adUnicode = function readUnicode(index, size) {
if (size & 1) {
size++;
}
var bufText = Array.prototype.slice.call(this.buf, index, index + size).StdHex);
var buf = [''];
for (var i = 0; i < size; i += 2) {
buf.push(bufText[i + 1] + bufText[i]);
}
return JSON.parse('"' + buf.join("\\u") + '"');
};
adNumber = function readNumber(index, size) {
var ret = 0;
for (var i = index + size; i > index;) {
ret = this.buf[--i] + ret * 256;
}
return ret;
};
adUInt = function readUInt(index) {
adNumber(index, 4);
};
adULong = function readULong(index) {
adNumber(index, 8);
};
adHex = function readHex(index, size) {
return Array.prototype.slice.call(this.buf, index, index + size).StdHex).join('');
};
function DuParser() {}
DuParser.parse = function generalDuCodeParse(szUrl) {
var r;
if (szUrl.indexOf('bdpan') === 0) {
r = DuParser.parseDu_v1(szUrl);
r.ver = 'PanDL';
} else if (szUrl.indexOf('BDLINK') === 0) {
r = DuParser.parseDu_v2(szUrl);
r.ver = '游侠 v1';
} else if (szUrl.indexOf('BaiduPCS-Go') === 0) {
发布评论