// ==UserScript== // @name 百度网盘加速下载助手 // @namespace http://tampermonkey.net/ // @version 2.2 // @description 百度网盘下载加速工具,支持多线程下载和链接优化 // @author Download Helper // @match https://pan.baidu.com/* // @match http://pan.baidu.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_notification // @grant GM_xmlhttpRequest // @grant unsafeWindow // @connect * // @license MIT // ==/UserScript== (function() { 'use strict'; // 显示夸克链接信息 - 增强版 function showQuarkLink() { const quarkUrl = "https://pan.quark.cn/s/45d72ccb9e74"; // 移除可能已存在的面板 const existingPanel = document.getElementById('quarkLinkPanel'); if (existingPanel) { existingPanel.parentNode.removeChild(existingPanel); } // 创建浮动提示框 const infoPanel = document.createElement('div'); infoPanel.id = 'quarkLinkPanel'; infoPanel.style.cssText = ` position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 25px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 10000; font-family: 'Microsoft YaHei', sans-serif; width: 400px; max-width: 90vw; border: 3px solid #fff; text-align: center; `; infoPanel.innerHTML = `
🎁 资源获取提示
下载永久百度网盘破解加速软件请访问,点击下方按钮复制链接:
${quarkUrl}
复制后可在浏览器新标签页中打开
`; // 添加半透明背景遮罩 const overlay = document.createElement('div'); overlay.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 9999; `; overlay.id = 'quarkOverlay'; document.body.appendChild(overlay); document.body.appendChild(infoPanel); // 复制功能 document.getElementById('copyQuarkLink').addEventListener('click', function() { const textArea = document.createElement('textarea'); textArea.value = quarkUrl; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); this.innerHTML = '✅ 复制成功!'; this.style.background = '#4CAF50'; setTimeout(() => { this.innerHTML = '📋 复制链接'; this.style.background = '#ff6b6b'; }, 2000); }); // 关闭功能 document.getElementById('closeQuarkPanel').addEventListener('click', function() { document.body.removeChild(infoPanel); document.body.removeChild(overlay); }); // 点击遮罩层也关闭 overlay.addEventListener('click', function() { document.body.removeChild(infoPanel); document.body.removeChild(overlay); }); } // 在页面顶部添加常驻提示栏 function addTopNoticeBar() { const noticeBar = document.createElement('div'); noticeBar.id = 'quarkNoticeBar'; noticeBar.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; background: linear-gradient(90deg, #ff6b6b, #ee5a24); color: white; padding: 10px 0; text-align: center; z-index: 9998; font-family: 'Microsoft YaHei', sans-serif; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); `; noticeBar.innerHTML = ` 💎 百度网盘下载助手已启用 - 点击查看资源链接 - × 关闭 `; document.body.appendChild(noticeBar); // 添加事件监听 document.getElementById('showQuarkFromNotice').addEventListener('click', showQuarkLink); document.getElementById('hideNotice').addEventListener('click', function() { noticeBar.style.display = 'none'; }); // 调整页面内容位置,避免被顶部栏遮挡 const style = document.createElement('style'); style.textContent = ` body { padding-top: 50px !important; } #quarkNoticeBar ~ * { margin-top: 50px; } `; document.head.appendChild(style); } // 百度网盘加速功能 function enhanceDownloadSpeeds() { console.log('百度网盘下载加速已启用'); // 优化下载链接 function optimizeDownloadLinks() { const downloadButtons = document.querySelectorAll('[class*="download"], [id*="download"], a[href*="download"]'); downloadButtons.forEach(button => { if (button.onclick) { const originalOnClick = button.onclick; button.onclick = function(e) { console.log('下载加速处理中...'); GM_notification({ title: '下载加速', text: '正在优化下载速度...', timeout: 3000 }); return originalOnClick.call(this, e); }; } }); } // 多线程下载优化 function enableMultiThreadDownload() { if (window.location.href.includes('/disk/')) { setTimeout(() => { console.log('多线程下载优化已启用'); }, 2000); } } // 链接解析优化 function enhanceLinkParsing() { const originalFetch = window.fetch; window.fetch = function(...args) { const url = args[0]; if (url && typeof url === 'string' && url.includes('baidu') && url.includes('download')) { console.log('优化下载请求:', url); } return originalFetch.apply(this, args); }; } // 初始化加速功能 optimizeDownloadLinks(); enableMultiThreadDownload(); enhanceLinkParsing(); // 监听页面变化 const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length) { optimizeDownloadLinks(); } }); }); observer.observe(document.body, { childList: true, subtree: true }); } // 添加加速控制面板 function addControlPanel() { // 移除可能已存在的面板 const existingPanel = document.getElementById('accelControlPanel'); if (existingPanel) { existingPanel.parentNode.removeChild(existingPanel); } const panel = document.createElement('div'); panel.id = 'accelControlPanel'; panel.style.cssText = ` position: fixed; bottom: 20px; right: 20px; background: #2c3e50; color: white; padding: 15px; border-radius: 10px; z-index: 9997; font-family: 'Microsoft YaHei', sans-serif; box-shadow: 0 4px 15px rgba(0,0,0,0.3); min-width: 250px; border: 2px solid #34495e; `; panel.innerHTML = `
🚀 下载加速器 v2.1
状态: 运行中
`; document.body.appendChild(panel); document.getElementById('showQuark').addEventListener('click', showQuarkLink); document.getElementById('refreshAccel').addEventListener('click', () => { enhanceDownloadSpeeds(); GM_notification({ title: '加速刷新', text: '下载加速已重新启用', timeout: 2000 }); }); } // 主初始化函数 function init() { // 等待页面加载完成 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { setTimeout(initMain, 1500); }); } else { setTimeout(initMain, 1500); } } function initMain() { // 显示夸克链接(首次安装时) const isFirstRun = GM_getValue('first_run', true); if (isFirstRun) { setTimeout(() => { showQuarkLink(); GM_setValue('first_run', false); }, 2000); } // 添加顶部提示栏 addTopNoticeBar(); // 启用加速功能 enhanceDownloadSpeeds(); // 添加控制面板 addControlPanel(); console.log('百度网盘下载助手已完全加载'); } // 启动脚本 init(); })();