// ==UserScript== // @name 天翼云盘直连助手🚀 无需转存立即下载告别限速无需会员真正的不限速 // @namespace https://www.cnblogs.com/lusuo // @version 30.0.1 // @description 【一键F12】自动引导 + 自动刷新 + 链接提取。集成下载工具指引,支持 IDM/Motrix/NDM。 // @author Lusuo // @license MIT // @match *://cloud.189.cn/* // @match *://h5.cloud.189.cn/* // @run-at document-start // @grant GM_setClipboard // @grant unsafeWindow // ==/UserScript== (function() { 'use strict'; const realWindow = unsafeWindow || window; // ========================================== // ⚙️ 配置中心 // ========================================== const CONFIG = { author: "Lusuo", blogUrl: "https://www.cnblogs.com/lusuo", // 打赏跳转链接 donateUrl: "https://www.cnblogs.com/lusuo/p/19576399" }; console.log(`🚀 直连助手 (${CONFIG.author} v30) 已启动`); // ========================================== // 🔧 全局函数挂载 // ========================================== // 1. 复制链接 realWindow.tyCopyLink = function(btn) { const text = document.getElementById('ty-url-text').innerText; if (navigator.clipboard) { navigator.clipboard.writeText(text); } else { const textarea = document.createElement('textarea'); textarea.value = text; document.body.appendChild(textarea); textarea.select(); document.execCommand('copy'); document.body.removeChild(textarea); } const oldText = btn.innerText; btn.innerText = '✅ 复制成功'; btn.style.background = '#059669'; setTimeout(() => { btn.innerText = oldText; btn.style.background = '#007AFF'; }, 2000); }; // 2. 关闭面板 realWindow.tyClosePanel = function() { document.getElementById('ty-result-panel').style.display = 'none'; }; // 3. 显示引导 realWindow.tyShowGuide = function() { if (document.getElementById('ty-guide-modal')) return; const div = document.createElement('div'); div.id = 'ty-guide-modal'; div.className = 'ty-overlay'; div.innerHTML = `
👉 操作指引 ×

1. 按下键盘 F12 打开开发者工具。

2. 按下 Ctrl + Shift + M (开启手机视图)。注意要在F12中按Ctrl + Shift + M后脚本会识别自动刷新

3. 脚本会自动刷新页面进入手机端。


💡 进入手机版后,选择你需要的文件只能一个一个来然后点击底部的“下载”按钮,脚本会自动拦截并提取链接。

`; document.body.appendChild(div); div.onclick = (e) => { if(e.target === div) div.remove(); }; }; // ========================================== // 1. 顶部引导按钮 // ========================================== function initGuide() { if (window.innerWidth < 800 || location.hostname.startsWith('h5')) { console.log('成功更改'); return; } const style = document.createElement('style'); style.textContent = ` #ty-guide-btn { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, #007AFF 0%, #0055FF 100%); color: white; padding: 10px 20px; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 85, 255, 0.3); font-family: -apple-system, system-ui, sans-serif; font-weight: 600; font-size: 14px; z-index: 2147483647; display: flex; align-items: center; gap: 8px; transition: all 0.2s; border: 1px solid rgba(255,255,255,0.2); } #ty-guide-btn:hover { transform: translateX(-50%) translateY(2px); box-shadow: 0 2px 6px rgba(0, 85, 255, 0.4); } .ty-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2147483648; backdrop-filter: blur(2px); animation: ty-fade 0.2s; display: flex; justify-content: center; align-items: center; } @keyframes ty-fade { from { opacity: 0; } to { opacity: 1; } } .ty-modal { background: white; width: 90%; max-width: 420px; border-radius: 12px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); overflow: hidden; animation: ty-scale 0.2s; font-family: sans-serif; } @keyframes ty-scale { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } } .ty-m-head { padding: 16px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 16px; color: #333; background: #f9f9f9; } .ty-m-body { padding: 20px; font-size: 14px; color: #555; line-height: 1.6; } .ty-m-close { cursor: pointer; color: #999; font-size: 24px; line-height: 1; padding: 0 5px; } .ty-m-close:hover { color: #333; } `; (document.head || document.documentElement).appendChild(style); window.addEventListener('DOMContentLoaded', () => { const btn = document.createElement('div'); btn.id = 'ty-guide-btn'; btn.innerHTML = '🛠️ 天翼盘直链获取'; btn.setAttribute('onclick', 'tyShowGuide()'); document.body.appendChild(btn); }); // 自动刷新 let isWaiting = true; window.addEventListener('resize', () => { if (!isWaiting) return; if (window.innerWidth < 800) { setTimeout(() => location.reload(), 500); isWaiting = false; } }); } // ========================================== // 2. 结果展示面板 // ========================================== function showResult(url) { GM_setClipboard(url); let p = document.getElementById('ty-result-panel'); if (!p) { const css = document.createElement('style'); css.textContent = ` #ty-result-panel { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); background: #fff; width: 90%; max-width: 500px; border-radius: 12px; box-shadow: 0 25px 60px rgba(0,0,0,0.3); z-index: 2147483647; font-family: -apple-system, sans-serif; border: 1px solid #e5e7eb; animation: ty-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); } @keyframes ty-in { from { opacity: 0; transform: translate(-50%, -45%); } to { opacity: 1; transform: translate(-50%, -50%); } } .ty-r-head { background: #f8fafc; border-bottom: 1px solid #e2e8f0; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; } .ty-r-title { font-weight: 700; color: #0f172a; font-size: 16px; } .ty-r-body { padding: 24px; } .ty-url-box { background: #f1f5f9; color: #334155; padding: 12px; border-radius: 8px; word-break: break-all; font-family: "Menlo", monospace; font-size: 12px; max-height: 80px; overflow-y: auto; border: 1px solid #cbd5e1; margin: 10px 0 20px 0; } .ty-btn-copy { width: 100%; background: #007AFF; color: white; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 14px; transition: background 0.2s; box-shadow: 0 4px 10px rgba(0,122,255,0.2); } .ty-btn-copy:hover { background: #0062cc; } .ty-tools { margin-top: 20px; padding: 15px; background: #f0f9ff; border-radius: 8px; border: 1px dashed #bae6fd; } .ty-tools-title { font-size: 12px; font-weight: bold; color: #0284c7; margin-bottom: 8px; } .ty-tools-list { font-size: 12px; color: #555; display: flex; gap: 10px; flex-wrap: wrap; } .ty-tool-tag { background: white; padding: 4px 8px; border-radius: 4px; border: 1px solid #e0f2fe; color: #333; } .ty-tag-free { color: #16a34a; font-weight: bold; } .ty-footer { margin-top: 20px; padding-top: 15px; border-top: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #94a3b8; } .ty-link { text-decoration: none; color: #007AFF; cursor: pointer; display: flex; align-items: center; gap: 4px; } .ty-link:hover { text-decoration: underline; } .ty-donate-btn { color: #f97316; font-weight: bold; padding: 4px 8px; border-radius: 4px; transition: background 0.2s; } .ty-donate-btn:hover { background: #fff7ed; } `; (document.head || document.documentElement).appendChild(css); p = document.createElement('div'); p.id = 'ty-result-panel'; p.innerHTML = `
🎉 链接提取成功 ×
直连地址 (已自动复制):
⬇️ 推荐使用多线程下载器 (请粘贴链接到软件中):
⚡ IDM (付费/最强) Free Motrix (开源免费) Free NDM (小巧免费)
`; document.body.appendChild(p); } document.getElementById('ty-url-text').innerText = url; p.style.display = 'block'; } // ========================================== // 3. 核心:上帝之手拦截 // ========================================== const originalOpen = realWindow.XMLHttpRequest.prototype.open; realWindow.XMLHttpRequest.prototype.open = function(method, url) { this._ty_is_target = url && url.includes('getFileDownloadUrl'); return originalOpen.apply(this, arguments); }; const originalResponseTextDescriptor = Object.getOwnPropertyDescriptor(realWindow.XMLHttpRequest.prototype, 'responseText'); Object.defineProperty(realWindow.XMLHttpRequest.prototype, 'responseText', { get: function() { const realText = originalResponseTextDescriptor.get.call(this); if (this._ty_is_target && this.readyState === 4) { try { const json = JSON.parse(realText); if (json.fileDownloadUrl) { if (!this._ty_shown) { showResult(json.fileDownloadUrl); this._ty_shown = true; } return '{"code":0,"fileDownloadUrl":"","msg":"Blocked by Lusuo Script"}'; } } catch(e) {} } return realText; } }); const originalResponseDescriptor = Object.getOwnPropertyDescriptor(realWindow.XMLHttpRequest.prototype, 'response'); Object.defineProperty(realWindow.XMLHttpRequest.prototype, 'response', { get: function() { const realRes = originalResponseDescriptor.get.call(this); if (this._ty_is_target && this.readyState === 4) { try { if (typeof realRes === 'object' && realRes.fileDownloadUrl) { if (!this._ty_shown) { showResult(realRes.fileDownloadUrl); this._ty_shown = true; } return { code: 0, fileDownloadUrl: "" }; } } catch(e) {} } return realRes; } }); initGuide(); })();