// ==UserScript== // @name 网盘直链下载助手 // @namespace https://github.com/syhyz1990/baiduyun // @version 6.1.0 // @author GreasyFork // @description 👆👆👆👆👆👆👆 - 支持批量获取 ✅百度网盘 ✅阿里云盘 ✅天翼云盘 ✅迅雷云盘 ✅夸克网盘 ✅移动云盘 六大网盘的直链下载地址,配合 IDM,Xdown,Aria2,Curl,比特彗星等工具高效🚀🚀🚀下载,完美适配 Chrome,Edge,FireFox,360,QQ,搜狗,百分,遨游,星愿,Opera,猎豹,Vivaldi,Yandex,Kiwi 等 18 种浏览器。可在无法安装客户端的环境下使用,助手免费开源。😎 // @license AGPL-3.0-or-later // @homepage https://www.youxiaohou.com/install.html // @supportURL https://github.com/syhyz1990/baiduyun // @antifeature membership // @match *://pan.baidu.com/disk/home* // @match *://yun.baidu.com/disk/home* // @match *://pan.baidu.com/disk/main* // @match *://yun.baidu.com/disk/main* // @match *://pan.baidu.com/s/* // @match *://yun.baidu.com/s/* // @match *://pan.baidu.com/share/* // @match *://yun.baidu.com/share/* // @match *://www.aliyundrive.com/s/* // @match *://www.aliyundrive.com/drive* // @match *://cloud.189.cn/web/* // @match *://pan.xunlei.com/* // @match *://pan.quark.cn/* // @match *://yun.139.com/* // @match *://caiyun.139.com/* // @require https://unpkg.com/jquery@3.6.0/dist/jquery.min.js // @require https://unpkg.com/sweetalert2@10.16.6/dist/sweetalert2.all.min.js // @require https://unpkg.com/js-md5@0.7.3/build/md5.min.js // @connect baidu.com // @connect baidupcs.com // @connect aliyundrive.com // @connect 189.cn // @connect xunlei.com // @connect quark.cn // @connect youxiaohou.com // @connect yun.139.com // @connect caiyun.139.com // @connect localhost // @connect * // @run-at document-idle // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // @grant GM_openInTab // @grant GM_info // @grant GM_registerMenuCommand // @grant GM_cookie // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciI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A1LjUgMS4zIDYuNiAzLjVsLjMuN2MuNyAyLjEuMSA0LjYtMS43IDYuOXoiIGZpbGw9IiM0NDQiLz48L3N2Zz4= // @downloadURL none // ==/UserScript== (function () { 'use strict'; let pt = '', selectList = [], params = {}, mode = '', width = 800, pan = {}, color = '', doc = $(document), progress = {}, request = {}, ins = {}, idm = {}; const scriptInfo = GM_info.script; const version = scriptInfo.version; const author = scriptInfo.author; const name = scriptInfo.name; const customClass = { popup: 'pl-popup', header: 'pl-header', title: 'pl-title', closeButton: 'pl-close', content: 'pl-content', input: 'pl-input', footer: 'pl-footer' }; const terminalType = { wc: "Windows CMD", wp: "Windows PowerShell", lt: "Linux 终端", ls: "Linux Shell", mt: "MacOS 终端", }; let toast = Swal.mixin({ toast: true, position: 'top', showConfirmButton: false, timer: 3500, timerProgressBar: false, didOpen: (toast) => { toast.addEventListener('mouseenter', Swal.stopTimer); toast.addEventListener('mouseleave', Swal.resumeTimer); } }); const message = { success: (text) => { toast.fire({title: text, icon: 'success'}); }, error: (text) => { toast.fire({title: text, icon: 'error'}); }, warning: (text) => { toast.fire({title: text, icon: 'warning'}); }, info: (text) => { toast.fire({title: text, icon: 'info'}); }, question: (text) => { toast.fire({title: text, icon: 'question'}); } }; let base = { getCookie(name) { let arr = document.cookie.replace(/\s/g, "").split(';'); for (let i = 0, l = arr.length; i < l; i++) { let tempArr = arr[i].split('='); if (tempArr[0] === name) { return decodeURIComponent(tempArr[1]); } } return ''; }, isType(obj) { return Object.prototype.toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase(); }, getValue(name) { return GM_getValue(name); }, setValue(name, value) { GM_setValue(name, value); }, getStorage(key) { try { return JSON.parse(localStorage.getItem(key)); } catch (e) { return localStorage.getItem(key); } }, setStorage(key, value) { if (this.isType(value) === 'object' || this.isType(value) === 'array') { return localStorage.setItem(key, JSON.stringify(value)); } return localStorage.setItem(key, value); }, setClipboard(text) { GM_setClipboard(text, 'text'); }, e(str) { return btoa(unescape(encodeURIComponent(str))); }, d(str) { return decodeURIComponent(escape(atob(str))); }, getExtension(name) { const reg = /(?!\.)\w+$/; if (reg.test(name)) { let match = name.match(reg); return match[0].toUpperCase(); } return ''; }, sizeFormat(value) { if (value === +value) { let unit = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; let index = Math.floor(Math.log(value) / Math.log(1024)); let size = value / Math.pow(1024, index); size = size.toFixed(1); return size + unit[index]; } return ''; }, sortByName(arr) { const handle = () => { return (a, b) => { const p1 = a.filename ? a.filename : a.server_filename; const p2 = b.filename ? b.filename : b.server_filename; return p1.localeCompare(p2, "zh-CN"); }; }; arr.sort(handle()); }, fixFilename(name) { return name.replace(/[!?&|`"'*\/:<>\\]/g, '_'); }, blobDownload(blob, filename) { if (blob instanceof Blob) { const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; a.click(); URL.revokeObjectURL(url); } }, post(url, data, headers, type) { if (this.isType(data) === 'object') { data = JSON.stringify(data); } return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "POST", url, headers, data, responseType: type || 'json', onload: (res) => { type === 'blob' ? resolve(res) : resolve(res.response || res.responseText); }, onerror: (err) => { reject(err); }, }); }); }, get(url, headers, type, extra) { return new Promise((resolve, reject) => { let requestObj = GM_xmlhttpRequest({ method: "GET", url, headers, responseType: type || 'json', onload: (res) => { if (res.status === 204) { requestObj.abort(); idm[extra.index] = true; } if (type === 'blob') { res.status === 200 && base.blobDownload(res.response, extra.filename); resolve(res); } else { resolve(res.response || res.responseText); } }, onprogress: (res) => { if (extra && extra.filename && extra.index) { res.total > 0 ? progress[extra.index] = (res.loaded * 100 / res.total).toFixed(2) : progress[extra.index] = 0.00; } }, onloadstart() { extra && extra.filename && extra.index && (request[extra.index] = requestObj); }, onerror: (err) => { reject(err); }, }); }); }, getFinalUrl(url, headers) { return new Promise((resolve, reject) => { let requestObj = GM_xmlhttpRequest({ method: "GET", url, headers, onload: (res) => { resolve(res.finalUrl); }, onerror: (err) => { reject(err); }, }); }); }, addStyle(id, tag, css) { tag = tag || 'style'; let doc = document, styleDom = doc.getElementById(id); if (styleDom) return; let style = doc.createElement(tag); style.rel = 'stylesheet'; style.id = id; tag === 'style' ? style.innerHTML = css : style.href = css; doc.getElementsByTagName('head')[0].appendChild(style); }, sleep(time) { return new Promise(resolve => setTimeout(resolve, time)); }, findReact(dom, traverseUp = 0) { const key = Object.keys(dom).find(key => { return key.startsWith("__reactFiber$") || key.startsWith("__reactInternalInstance$"); }); const domFiber = dom[key]; if (domFiber == null) return null; if (domFiber._currentElement) { let compFiber = domFiber._currentElement._owner; for (let i = 0; i < traverseUp; i++) { compFiber = compFiber._currentElement._owner; } return compFiber._instance; } const GetCompFiber = fiber => { let parentFiber = fiber.return; while (typeof parentFiber.type == "string") { parentFiber = parentFiber.return; } return parentFiber; }; let compFiber = GetCompFiber(domFiber); for (let i = 0; i < traverseUp; i++) { compFiber = GetCompFiber(compFiber); } return compFiber.stateNode || compFiber; }, initDefaultConfig() { let value = [{ name: 'setting_rpc_domain', value: 'http://localhost' }, { name: 'setting_rpc_port', value: '16800' }, { name: 'setting_rpc_path', value: '/jsonrpc' }, { name: 'setting_rpc_token', value: '' }, { name: 'setting_rpc_dir', value: 'D:' }, { name: 'setting_terminal_type', value: 'wc' }, { name: 'setting_theme_color', value: '#09AAFF' }, { name: 'setting_init_code', value: '' }]; value.forEach((v) => { base.getValue(v.name) === undefined && base.setValue(v.name, v.value); }); }, showSetting() { let dom = '', btn = '', colorList = ['#09AAFF', '#cc3235', '#526efa', '#518c17', '#ed944b', '#f969a5', '#bca280']; dom += ``; dom += ``; dom += ``; dom += ``; dom += ``; colorList.forEach((v) => { btn += `
`; }); dom += ``; dom += `