百度网盘当前目录压缩文件一键解压
当前为
// ==UserScript==
// @name 百度网盘一键解压缩
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 百度网盘当前目录压缩文件一键解压
// @match https://pan.baidu.com/*
// @require https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
let btnToolHTML = '<a class="g-button" href="javascript:;" title="批量解压" style="display: inline-block;"><span class="g-button-right"><em class="icon icon-remark-remove" title="批量重命名"></em><span class="text" style="width: auto;">批量解压</span></span></a>';
$(btnToolHTML).appendTo('.tcuLAu').click(function() {
unZip();
return false;
});
let baidu_tips = require('system-core:system/uiService/tip/tip.js');
let folders = $.grep($('.file-name .text a'), function(element, index) {
return !/\.\w{2,4}$/ig.test($(element).text());
}).map(function(item, index) {
return $(item).text();
});
async function unZip() {
let password = prompt('请输入解压密码,没有密码为空即可', '');
let path = $('.FuIxtL li[node-type] span:last');
path = path.attr('title').replace('全部文件', '') + '/';
// let unzipFiles = $.grep($('.file-name .text a'), function(element, index) {
// return /\.(zip|rar)/ig.test($(element).text());
// }).map(function(element,index){
// return $(element).replace(/\.(zip|rar)/ig, '');
// });
//
// let zipedPath = $.grep($('.file-name .text a'), function(element, index) {
// return /^((?!\.rar|\.zip$).)*$/ig.test($(element).text());
// });
//
// unzipFiles = unzipFiles.filter(key => !zipedPath.includes(key));
let options = $.grep($('.file-name .text a'), function(element, index) {
return /\.(zip|rar)$/ig.test($(element).text()) && !folders.includes($(element).text().replace(/\.(zip|rar)$/ig, ''));
}).map(function(element, index) {
let option = {
path: path + $(element).text(),
subpath: JSON.stringify(['/' + $(element).text().replace(/\.(zip|rar)$/ig, '')]),
topath: path,
type: 'unzip',
channel: 'channel',
web: 1,
app_id: '250528',
bdstoken: yunData.MYBDSTOKEN
};
return password == '' ? option : $.extend(option, {
password: password
});
});
for (let i = 0; i < options.length; i++) {
// window.yunHeader.tools.ui.tip.show({
// msg: `正在解压第${i}个文件,共${options.length}个文件`,
// type: 'success'
// });
baidu_tips.show({
mode: "loading",
msg: `正在解压第${i+1}个文件,共${options.length}个文件`,
autoClose: !1
});
await ajaxUnZip(options[i]);
}
window.yunHeader.tools.ui.tip.show({
msg: `全部解压命令发送完成,正在刷新页面……`,
type: 'success'
});
setTimeout(function() {
location.reload(true);
}, 4000);
}
function ajaxUnZip(options) {
return new Promise((resolve, reject) => {
$.ajax('https://pan.baidu.com/api/zipfile/copy', {
data: options,
type: 'GET',
complete: function() {
setTimeout(function() {
resolve(true);
}, 2000);
}
});
});
}
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址