// ==UserScript== // @name 雷利子 // @namespace https://github.com/oneNorth7/Cloud189_popper // @version 0.1.6 // @author 一个北七 // @description 简单突破天翼云盘网页版文件下载的大小, 多文件, 文件夹限制; 单选、多选、全选文件直接下载; 逐个文件直接下载并根据情况复制目录名称 // @icon https://gitee.com/oneNorth7/pics/raw/master/picgo/pentagram-devil.png // @created 2021/3/13 下午6:23:05 // @include http*://cloud.189.cn/* // @noframes // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js // @require https://cdn.jsdelivr.net/npm/sweetalert2@10.15.5/dist/sweetalert2.all.min.js // @run-at document-end // @grant unsafeWindow // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @grant GM_setClipboard // @note V0.1.6 更换图标;新增逐个文件/文件夹直接下载功能;新增打包下载时根据情况复制文件名功能 // @downloadURL none // ==/UserScript== void function() { 'use strict'; const sizeLimit = 50 * 1<<10 * 1<<10; const buttonText = '\u76f4\u63a5\u4e0b\u8f7d'; const buttonStyle = {'background-color': '#36BE63', 'color': 'white'}; let t = { clog(msg) { console.group('[雷利子]'); for (let m of arguments) { if (void 0 !== m) console.log(m); } console.groupEnd(); }, set(name, value) { GM_setValue(name, value); }, get(name, def) { return GM_getValue(name, def); }, registerMenu(title, func) { return GM_registerMenuCommand(title, func); }, copy(text, type='text/plain') { GM_setClipboard(text, type); }, increase() { success_times = +this.get("success_times") + 1; this.set("success_times", success_times); }, subscribe() { let isFollowed = t.get('isFollowed', false), least_times = t.get('least_times', 100); success_times = +this.get("success_times"); if (success_times > least_times && !isFollowed) { Swal.fire({ title: '\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e0d\u8ff7\u8def\uff01', html: $( `
\u7b2c\u4e00\u65f6\u95f4\u83b7\u53d6\u66f4\u65b0\u63a8\u9001\uff01\uff01\uff01
是否全部逐一下载?
`, icon: 'warning', showCancelButton: true, allowOutsideClick: false, confirmButtonColor: '#d33', confirmButtonText: '确定全部下载', cancelButtonColor: '#3085d6', cancelButtonText: '取消下载', }).then((result) => { if (result.isConfirmed) { directDownload(); t.info('封印解除!', '全部文件开始逐一下载', 'success'); } }); } }, showInfo() { let view = this.getView(), fileIdList = this.getFileIdList(view), fileList = this.getFileList(), panType = this.getPanType(), msg = ''; switch(panType) { case 0: case 2: if ($('a.J_Download').hasClass('disable')) { t.info('系统生成文件夹', '无法直接下载,请进入文件夹下载!'); return ; } if (fileIdList) { if (fileIdList.includes(',') ) { msg += '成功突破文件数量限制!'; } else { msg += this.breakSingleSize(fileList.selected()[0]); } } if (this.isFolderSelected()) msg = msg ? msg.replace('限制', '和文件夹限制') : '成功突破文件夹限制!'; break; case 1: msg += '成功突破文件大小限制!'; break; } t.increase(); if (msg) t.info('封印解除!', msg, 'success'); }, hideTip() { $('div.tips-save-box').hide(); }, changeStyleOne() { if (unsafeWindow.fileSize >= sizeLimit) { this.enableButton(); $('a.download-link').css(buttonStyle).text(buttonText); this.showInfo(); } this.hideTip(); }, changeStyleTwo() { $('div.file-item').on('click', () => { $('#J_Download').css(buttonStyle).text(buttonText); this.hideTip(); }); $('.file-list-hd .col-checkbox').on('click', () => { setTimeout(() => { $('#J_Download').css(buttonStyle).text(buttonText); this.hideTip(); }, 2000); }); this.addListener(); }, changeStyleZero() { $('.file-item-container>.file-item').on('click', () => { $('.file-list-container div.btn-group .dropdown').css('width','320px'); $('a.J_Download').css(buttonStyle).text(buttonText); }); $('.file-list-hd .col-checkbox').on('click', () => { setTimeout(() => { $('.file-list-container div.btn-group .dropdown').css('width','320px'); $('a.J_Download').css(buttonStyle).text(buttonText); }, 2000); }); this.addListener(); }, addListener() { $('a.J_Download, #J_Download').on('click', () => { this.enableButton(); this.securityOn(); this.copyFolderName(); this.showInfo(); }); $('div.file-item-container a.download-link').on('click', (obj) => { $(obj.target).parents('div.file-item').click(); $('a.J_Download, #J_Download')[0].click(); }); $('a.open-link, ul.breadcrumb a').on('click', () => { setTimeout(() => { this.changeButton(); }, 1000); this.addButton(); }); $('a.allfile').on('click', () => { setTimeout(() => { this.addButton(); }, 1000); }); this.addButton(); }, addButton() { let downloadLink = $('div.file-item-container:visible>.file-item'); let newButton = this.newButton, name = this.getFolderName(); if (downloadLink.length > 1 && name.length <= 1) { let operate = $('a.btn-save-as'); if (operate.length && !$('#J_download1by1').length) { this.newButton = $('逐个下载') operate.before(this.newButton); } let bar = $('div.toolbar>.btn-group'); if (bar.length && !$('#J_download1by1').length) { this.newButton = $('逐个下载') bar.append(this.newButton); } $('#J_download1by1').on('click', () => { this.download1by1(); }); } else if (newButton) newButton.remove(); }, changeButton() { let panType = this.getPanType(); switch(panType) { case 0: this.changeStyleZero(); break; case 1: this.changeStyleOne(); break; case 2: this.changeStyleTwo() break; } }, isLogin() { return unsafeWindow.application.headerView.isLogin; }, init() { setTimeout(() => { if (this.isLogin()) { this.changeButton(); t.clog('加载成功!'); } else { Swal.fire('请先登录!', '必须登录才能突破下载限制', 'error'); } }, 2500); }, }; main.init(); }();