您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
天翼云盘大文件免客户端直接下载文件,支持2021年6月份改版后的天翼云盘。
当前为
// ==UserScript== // @name 天翼云盘助手 // @description 天翼云盘大文件免客户端直接下载文件,支持2021年6月份改版后的天翼云盘。 // @version 2.0.10 // @namespace TyCloud_Tools // @icon https://z3.ax1x.com/2021/05/31/2m1BTA.png // @author 邓小明 // @include *//cloud.189.cn/* // @require https://cdn.bootcdn.net/ajax/libs/jquery/2.1.4/jquery.min.js // @run-at document-start // @grant unsafeWindow // ==/UserScript== (function () { 'use strict'; $(document).ready(function () { init(); }); })(); function init() { //console.log('初始化网盘助手' + unsafeWindow.location.pathname); var append_html = ` <style type="text/css"> .show_file_list_btn{ cursor:pointer; display:none; position: relative; left: 60px; bottom: 160px; position:fixed; z-index: 998; } .show_file_list_btn span{ position: relative; } .show_file_list_btn span::after { position: absolute; left: 0; top: 0; content: '直链'; width: 50px; height: 50px; line-height: 50px; border-radius:50%; cursor:pointer; font-size: 14px; background-color: rgba(0,0,0,0.8); background-image:linear-gradient(286deg,#4CA0FC 23%,#E02FEE 76%); opacity: .9; color: #fff; text-align:center; box-shadow: 1px 1px 10px rgba(0,0,0,0.2); animation: rotate 0.5s linear infinite; } .show_file_list_btn span::before { content: ''; height: 8px; width: 50px; background: #000; opacity: .15; border-radius: 50%; position: absolute; top: 67px; left: 0; animation: shadow 0.5s linear infinite; } @keyframes shadow { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(1.2); } } @keyframes rotate { 0% { transform: translateY(0); } 25% { transform: translateY(10px); } 50% { transform: translateY(20px) scale(1.1, 0.9); } 75% { ransform: translateY(10px); } 100% { transform: translateY(0); } } .show_file_list { background-color: rgba(0,0,0,0.65); backdrop-filter:blur(5px); width:100vw; height: 100vh; z-index: 999; left: 0px; top: 0; position:fixed; } .show_file_list .td-dialog{ background-color: #fff; width:80%; max-width: 600px; min-height: 300px; margin:10vh auto 0; border-radius:5px; box-shadow: 1px 3px 24px rgba(0,0,0,0.2); } .show_file_list .td-dialog .td-dialog__header{ line-height: 44px; padding:5px 10px; border-radius:5px 5px 0 0; background-color:#f1f1f1; overflow: hidden; position: relative; } .show_file_list .td-dialog h2{ font-size: 20px; color:#333; font-weight:600; } .show_file_list .td-dialog .td-dialog__close{ position: absolute; right: 14px; top: 18px; width: 24px; height: 24px; background: url("data:image/svg+xml,%3Csvg viewBox='0 0 1045 1024' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath d='M282.517333 213.376l-45.354666 45.162667L489.472 512 237.162667 765.461333l45.354666 45.162667L534.613333 557.354667l252.096 253.269333 45.354667-45.162667-252.288-253.44 252.288-253.482666-45.354667-45.162667L534.613333 466.624l-252.096-253.226667z' %3E%3C/path%3E%3C/svg%3E") center center no-repeat; background-size: 100% auto; opacity: .6; cursor: pointer; -webkit-transition: all ease .3s; transition: all ease .3s; } .show_file_list .td-dialog .td-dialog__close:hover{ -webkit-transform:rotate(90deg); transform:rotate(90deg); opacity:.8; } .show_file_list .td-dialog__body{ clear:both; padding-bottom: 5px } .show_file_list ul{ min-height: 150px; max-height: 300px; overflow-y: auto; background-color: #fff; } .show_file_list li{ cursor:pointer; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; word-break: break-all; border-bottom:1px dashed #eee; font-size: 14px; line-height: 42px; padding:0 10px; } .show_file_list li:hover{ background-color: #f8f8f8; } .show_file_list li span{ color: #3f85ff; } .show_file_list li i{ font-size:12px; color: #999; font-style:normal; } #file_direct_link{ margin:5px; background-color: #f5efff; font-size:12px; line-height:26px; max-height:78px; overflow-y:auto; border-radius:5px; padding-left:5px; word-break:break-all; } #file_direct_link a{ color: #3f85ff; line-height:26px; } </style> <div class="show_file_list_btn" title="查看当前页文件直链"><span></span></div> <div class="show_file_list"> <div class="td-dialog"> <div class="td-dialog__header"> <h2>下载直链</h2> <span title="关闭" class="td-dialog__close"></span> </div> <div class="td-dialog__body"> <ul class="folder_list"></ul> <div id="file_direct_link"></div> </div> </div> </div> `; $('body').append(append_html); $('.show_file_list').hide(); $('.show_file_list_btn').on('click', function () { $('.show_file_list_btn').fadeOut(); $('.show_file_list').fadeIn(); }); $('.show_file_list .td-dialog__close').on('click', function () { $('.show_file_list_btn').fadeIn(); $('.show_file_list').fadeOut(); $('#file_direct_link').empty(); }); } var share_id = ''; var request_proxied = unsafeWindow.XMLHttpRequest.prototype.open; unsafeWindow.XMLHttpRequest.prototype.open = function () { this.addEventListener('load', function () { if (this.status == 200 && this.response) { var url = this.responseURL; if (url.indexOf('getUserInfoForPortal.action') > -1) { //console.log('用户信息', this.response); } else if (url.indexOf('file/listFiles.action') > -1) { //console.log('文件列表', this.response); if (this.response.res_code == 0) { show_file_list(this.response.fileListAO); } } else if (url.indexOf('share/listShareDir.action') > -1) { //console.log('分享列表', json); if (this.response.res_code == 0) { show_file_list(this.response.fileListAO); } } else if (url.indexOf('share/getShareInfoByCode.action') > -1) { if(this.response.shareId){ share_id = this.response.shareId; } else { share_id = ''; } } else if (url.indexOf('getFileDownloadUrl.action') > -1) { //console.log('文件下载', this.response); } else { } } }); return request_proxied.apply(this, [].slice.call(arguments)); }; function show_file_list(data) { $('.show_file_list .folder_list').empty(); if (data.count > 0 || data.fileListSize > 0) { $('.show_file_list_btn').fadeIn(); $.each(data.folderList, function (index, item) { $('.show_file_list .folder_list').append('<li class="show_folder" data-id="' + item.id + '" title="进入文件夹:' + item.name + '"><span>' + item.name + '</span></li>'); }); $.each(data.fileList, function (index, item) { $('.show_file_list .folder_list').append('<li class="show_file file_' + item.id + '" data-id="' + item.id + '" title="点击获取直链:' + item.name + '"><span>' + item.name + '</span> <i>' + conver(item.size) + '</i></li>'); var file_list_item = $('.file-list-ul .c-file-list-item[data-fileid=' + item.id + ']'); /* 点击文件名下载 */ file_list_item.find('.file-item-name-fileName-span').attr('title', '点击下载').off('click').on('click', function (e) { var file_id = $(this).parents('.c-file-list-item').data('fileid'); get_file_download_url(file_id, share_id, 0); }); if(item.size >= 50*1024*1024){ /* 替换打开客户端下载按钮 */ var data_v = 'data-v-' + (/data-v-(\w+)/.exec(file_list_item.html())[1]); file_list_item.find('.file-item-ope-item-download').parent().remove(); file_list_item.find('.file-item-ope .file-item-ope-item').eq(0).after('<div ' + data_v + ' class="file-item-ope-item direct-download"><span ' + data_v + ' class="file-item-ope-item-icon file-item-ope-item-download"></span></div>'); file_list_item.find('.file-item-ope-item-download').parent().attr('title', '直链下载').off('click').on('click', function (e) { var file_id = $(this).parents('.c-file-list-item').data('fileid'); get_file_download_url(file_id, share_id, 0); }); } }); $('.show_file_list .show_folder').off('click').on('click', function (e) { $('.file-list-ul .c-file-list-item[data-fileid=' + $(this).data('id') + '] .file-item-name-fileName-span').trigger('click'); }); $('.show_file_list .show_file').off('click').on('click', function (e) { $('#file_direct_link').empty(); get_file_download_url($(this).data('id'), share_id, 1); }); } else { $('.show_file_list_btn').fadeOut(); } } function get_file_download_url(fileid, shareid, show_link) { $.ajax({ url: '/api/open/file/getFileDownloadUrl.action', data: { fileId: fileid, shareId: shareid }, dataType: 'xml', success: function (data) { var fileName = $('.file-list-ul .c-file-list-item[data-fileid=' + fileid + '] .file-item-name-fileName-span').text(); var fileDownloadUrl = $(data).find('fileDownloadUrl').text() + '&fileName=' + encodeURIComponent(fileName); if(show_link == 1){ $('#file_direct_link').html('<b>直链网址:</b><a href="' + fileDownloadUrl + '" target="_blank" title="点击下载:' + fileName + '">' + fileDownloadUrl + '</a>'); } unsafeWindow.location.href = fileDownloadUrl; } }); } function conver(limit) { var size = ''; if (limit < 0.1 * 1024) { size = limit.toFixed(2) + 'B'; } else if (limit < 0.1 * 1024 * 1024) { size = (limit / 1024).toFixed(2) + 'KB'; } else if (limit < 0.1 * 1024 * 1024 * 1024) { size = (limit / (1024 * 1024)).toFixed(2) + 'MB'; } else { size = (limit / (1024 * 1024 * 1024)).toFixed(2) + 'GB'; } var sizestr = size + ''; var len = sizestr.indexOf('\.'); var dec = sizestr.substr(len + 1, 2); if (dec == '00') { return sizestr.substring(0, len) + sizestr.substr(len + 3, 2); } return sizestr; }