// ==UserScript==
// @name 百度网盘文件直链解析助手尊享版
// @namespace https://www.qyccc.com/
// @version 0.10
// @description 百度网盘免会员文件直链解析满速下载
// @author 清语尘
// @match *://pan.baidu.com/*
// @match *://speed.icy6.cn/*
// @exclude *://pan.baidu.com/aipan/search*
// @require https://lib.baomitu.com/jquery/1.11.1/jquery.min.js
// @require https://scriptcat.org/lib/637/1.4.7/ajaxHooker.js#sha256=xi2KoJLxtSQlpI84FlKZ9KubxQ15+MxSa6aoM2y134I=
// @require https://cdnjs.loli.net/ajax/libs/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js
// @icon https://android-artworks.25pp.com/fs08/2025/09/05/3/110_a434d925c0416fd0188b2d7fea68d7fb_con.png
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_notification
// @grant GM_addStyle
// @run-at document-end
// @license MIT
// ==/UserScript==
(function() {
'use strict';
GM_addStyle(`
.swal2-popup {
transition: all 0.3s ease-out !important;
}
#qyc-con iframe {
border-radius: 8px;
}
.swal2-container {
z-index: 100000 !important;
}
`);
if (window.location.href.includes('/aipan/search')) {
return;
}
let isDialogOpen = false;
let hasBoundCopyEvents = false;
let currentShareData = null;
if (window.location.hostname === 'speed.icy6.cn') {
handleAnalysisSite();
} else if (window.location.hostname.includes('baidu.com')) {
handleBaiduNetdisk();
}
function handleAnalysisSite() {
function hideSider() {
const sider = document.querySelector('.t-layout__sider');
const targetDiv = document.querySelectorAll('.t-card--bordered');
const targetTip = document.querySelectorAll('.t-card__body .t-space.t-space-vertical.space .t-space-item');
const branges = document.querySelector('.t-form-item__token');
const inputBranges = document.querySelector('.t-form-item__token input');
const messageElement = document.querySelector('.t-message.t-is-error');
if (messageElement){
messageElement.style.display = 'none';
}
if (sider) {
sider.style.display = 'none';
targetTip[1].style.display = 'none';
branges.style.display = 'none';
inputBranges.removeAttribute('value');
inputBranges.type = 'password';
inputBranges.value = GM_getValue('brange', null);
if(targetDiv.length > 1){
targetDiv[0].style.display = 'none';
}
observer.disconnect();
}
}
function autoFillForm() {
const shareData = GM_getValue('baidu_share_data', null);
if (shareData && shareData.link) {
const inputs = document.querySelectorAll('.t-input__inner');
if (inputs.length > 0) {
inputs[0].value = shareData.link;
inputs[3].value = GM_getValue('brange', null);
const inputEvent = new Event('input', { bubbles: true });
inputs[0].dispatchEvent(inputEvent);
inputs[3].dispatchEvent(inputEvent);
inputs[0].focus();
inputs[3].focus();
console.log('已自动填写分享链接: ' + shareData.link);
GM_setValue('baidu_share_data', null);
GM_setValue('brange', null);
setTimeout(function(){
inputs[0].blur();
inputs[3].blur();
}, 300);
setTimeout(function(){
inputs[3].removeAttribute('value');
localStorage.removeItem('token');
}, 1000);
}
}
}
// 使用MutationObserver监听DOM变化
const observer = new MutationObserver(function(mutations) {
hideSider();
autoFillForm();
});
observer.observe(document.body, { childList: true, subtree: true });
// 初始执行
hideSider();
autoFillForm();
}
function handleBaiduNetdisk() {
if (typeof $ === 'undefined') {
setTimeout(handleBaiduNetdisk, 100);
return;
}
$(document).ready(function() {
setupShareListener();
});
}
function setupShareListener() {
let shareData = {
link: '',
code: ''
};
// 使用事件委托绑定复制按钮
function bindCopyButtonEvents() {
if (hasBoundCopyEvents) return;
// 使用事件委托处理复制按钮点击
document.addEventListener('click', function(e) {
const target = e.target;
const copyButton = target.closest('.u-button.wp-share-file__link-create-ubtn');
if (copyButton && copyButton.textContent.includes('复制中')) {
setTimeout(() => {
if(copyButton.textContent.includes('复制链接')){
navigator.clipboard.readText().then(text => {
if (text.includes('pan.baidu.com')) {
processShareText(text);
}
}).catch(err => {
console.log('无法读取剪贴板:', err);
Swal.fire({
position: 'center',
icon: 'info',
title: '读取剪贴板失败',
text: '稍后请手动将分享的链接粘贴到链接输入框中即可!',
imageUrl: 'https://www.pupp.top/gzh.jpg',
imageWidth: 200,
imageAlt: '微信公众号【干货老周】',
showConfirmButton: true,
timer: 5000,
timerProgressBar: true
});
extractShareInfoFromPage();
});
}else{
Swal.fire({
position: 'center',
icon: 'error',
title: '程序运行错误',
text: '您的本地网络较慢,请暂停其他占用网络的程序再试!',
imageUrl: 'https://www.pupp.top/gzh.jpg',
imageWidth: 200,
imageAlt: '微信公众号【干货老周】',
showConfirmButton: true,
timer: 5000,
timerProgressBar: true
});
}
}, 2000);
}
});
hasBoundCopyEvents = true;
}
// 使用防抖函数避免频繁触发
const debounce = (func, wait) => {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
// 处理分享弹窗的函数
const handleShareDialog = debounce(function(shareDialog) {
if (!shareDialog) return;
findShareInfo(shareDialog);
bindCopyButtonEvents();
}, 300);
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
const shareDialog = document.querySelector('.wp-s-share-hoc__dialog');
if (shareDialog) {
handleShareDialog(shareDialog);
}
}
});
});
observer.observe(document.body, { childList: true, subtree: true });
// 从页面元素提取分享信息
function extractShareInfoFromPage() {
// 查找包含分享链接的元素
const linkElements = document.querySelectorAll('[class*="link"], [class*="url"], [class*="share"]');
for (let el of linkElements) {
if (el.textContent.includes('pan.baidu.com')) {
processShareText(el.textContent);
return;
}
}
// 查找提取码
const codeElements = document.querySelectorAll('[class*="code"], [class*="pwd"], [class*="password"]');
for (let el of codeElements) {
const codeMatch = el.textContent.match(/([a-zA-Z0-9]{4})/);
if (codeMatch && codeMatch[1]) {
shareData.code = codeMatch[1];
GM_setValue('baidu_share_data', shareData);
break;
}
}
}
// 处理分享文本
function processShareText(text) {
// 检查是否已经处理过相同的分享数据
const linkMatch = text.match(/https?:\/\/pan\.baidu\.com\/s\/[^\s]+/);
if (!linkMatch) return;
const newLink = linkMatch[0];
// 如果是相同的分享链接且已经处理过,则不再处理
if (currentShareData && currentShareData.link === newLink) {
return;
}
shareData.link = newLink;
// 提取提取码
const codeMatch = text.match(/提取码[::]\s*([a-zA-Z0-9]{4})/);
if (codeMatch && codeMatch[1]) {
shareData.code = codeMatch[1];
} else {
const codeMatch2 = text.match(/([a-zA-Z0-9]{4})/);
if (codeMatch2 && codeMatch2[1]) {
shareData.code = codeMatch2[1];
}
}
// 存储当前分享数据
currentShareData = {...shareData};
GM_setValue('baidu_share_data', shareData);
const shareDialog = document.querySelector('.wp-s-share-hoc__dialog');
if (shareDialog) {
const closeButton = shareDialog.querySelector('.u-dialog__headerbtn');
if (closeButton) {
setTimeout(function(){
closeButton.click();
}, 500);
}
}
if (isDialogOpen) {
Swal.close();
}
Swal.fire({
position: 'top-end',
icon: 'success',
title: '已捕获分享链接!',
text: '将自动打开解析页面并填充...',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didClose: () => {
isDialogOpen = false;
}
});
isDialogOpen = true;
setTimeout(function(){
Swal.close();
initVerification();
}, 3500);
console.log('已捕获分享链接: ' + shareData.link);
if (shareData.code) {
console.log('已捕获提取码: ' + shareData.code);
}
}
// 在分享弹窗中查找分享信息
function findShareInfo(dialog) {
// 查找所有文本内容
const textContent = dialog.textContent;
if (textContent.includes('pan.baidu.com')) {
processShareText(textContent);
}
// 查找特定的输入框或显示区域
const inputs = dialog.querySelectorAll('input, textarea, [class*="link"], [class*="url"]');
for (let input of inputs) {
if (input.value && input.value.includes('pan.baidu.com')) {
processShareText(input.value);
break;
} else if (input.textContent && input.textContent.includes('pan.baidu.com')) {
processShareText(input.textContent);
break;
}
}
}
function initVerification() {
const lastVerified = GM_getValue('lastVerified', '');
const today = new Date().toDateString();
if (lastVerified === today) {
GM_xmlhttpRequest({
method: "GET",
url: "https://pp.pupp.top/code/",
headers: {
"Referer": "https://pan.baidu.com/"
},
onload: function(response) {
try {
const data = JSON.parse(response.responseText);
if (data.code) {
GM_setValue('brange', data.rand);
} else {
console.log(data.error || "获取失败");
}
} catch (e) {
console.log("解析响应失败: " + e.message);
}
},
onerror: function(error) {
console.log("网络请求失败: " + error.statusText);
}
});
showSuccessMessage();
return;
}
showVerificationDialog();
}
function showVerificationDialog() {
Swal.fire({
title: "输入今日验证码",
input: "text",
inputAttributes: {
autocapitalize: "off",
maxlength: "4",
placeholder: "请移步公众号获取今日验证码",
pattern: "[0-9]{4}",
inputmode: "numeric"
},
inputValidator: (value) => {
if (!value || value.length !== 4) {
return "请输入4位数字验证码";
}
if (!/^\d{4}$/.test(value)) {
return "验证码必须是4位数字";
}
},
imageUrl: 'https://www.pupp.top/gzh.jpg',
imageWidth: 200,
imageAlt: '微信公众号【干货老周】',
showCancelButton: false,
allowOutsideClick: false,
confirmButtonText: "验证",
showLoaderOnConfirm: true,
preConfirm: async (inputValue) => {
try {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: "https://pp.pupp.top/code/",
headers: {
"Referer": "https://pan.baidu.com/"
},
onload: function(response) {
try {
const data = JSON.parse(response.responseText);
if (data.code) {
GM_setValue('brange', data.rand);
resolve({
input: inputValue,
apiCode: data.code
});
} else {
reject(new Error(data.error || "获取验证码失败"));
}
} catch (e) {
reject(new Error("解析响应失败: " + e.message));
}
},
onerror: function(error) {
reject(new Error("网络请求失败: " + error.statusText));
}
});
});
} catch (error) {
Swal.showValidationMessage(`请求失败: ${error}`);
}
},
allowOutsideClick: () => !Swal.isLoading()
}).then((result) => {
if (result.isConfirmed) {
const { input, apiCode } = result.value;
if (input === apiCode) {
GM_setValue('lastVerified', new Date().toDateString());
Swal.fire({
icon: 'success',
title: '验证成功',
text: '感谢你的支持!现在可享受今日全天免费下载!',
confirmButtonText: '确定'
}).then(() => {
showSuccessMessage();
});
} else {
Swal.fire({
icon: 'error',
title: '验证失败',
text: '验证码输入错误,请移步公众号获取今日验证码!',
confirmButtonText: '重试'
}).then(() => {
showVerificationDialog();
});
}
}
});
}
function showSuccessMessage() {
Swal.fire({
title: '<strong>文件直链解析助手尊享版</strong>',
footer: '<div style="text-align:center">感谢公益解析平台提供的服务,本脚本仅提供集成便于使用<br>详细使用说明:微信公众号关注【干货老周】发送“百度网盘解析”获取</div>',
width: 1024,
html: '<div id="qyc-con" style="position: relative; padding: 30% 45%;"><iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0;" src="https://speed.icy6.cn/user/parse" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" allowtransparency> </iframe> </div>',
showCloseButton: true,
showConfirmButton: false,
showCancelButton: false,
allowOutsideClick: false,
didOpen: () => {
isDialogOpen = true;
},
willClose: () => {
isDialogOpen = false;
currentShareData = null;
}
});
}
setTimeout(() => {
if (!isDialogOpen) {
Swal.fire({
position: 'center',
icon: 'success',
title: '直链解析助手初始化成功!',
html: '请正常分享一个或多个要下载的文件或文件夹,系统获取到分享链接将自动运行下一步!',
footer: '<div style="text-align:center;font-size:small">详细使用说明:扫码关注微信公众号【干货老周】发送“百度网盘解析”获取</div>',
imageUrl: 'https://www.pupp.top/gzh.jpg',
imageWidth: 200,
imageAlt: '微信公众号【干货老周】',
showConfirmButton: true,
timer: 10000,
timerProgressBar: true
});
}
}, 1000);
}
})();