您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
天翼云盘跳过客户端直接下载文件,支持2021年6月份改版后的天翼云盘。
当前为
// ==UserScript== // @name 天翼云盘助手 // @description 天翼云盘跳过客户端直接下载文件,支持2021年6月份改版后的天翼云盘。 // @version 2.0.2 // @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.85); 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; } .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; } .show_file_list .td-dialog h2{ float:left; font-size: 20px; color:#333; font-weight:600; } .show_file_list .td-dialog .td-dialog__close{ float:right; font-size: 20px; color: #b3b3b3; margin-right:10px; } .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{ 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 a{ color: #3f85ff; width:100%; display:inline-block; } .show_file_list li a 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> <a href="javascript:;" title="关闭" class="td-dialog__close">X</a> </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 if (url.indexOf('getFileDownloadUrl.action') > -1) { //console.log('文件下载', this.response); } else { } } }); return request_proxied.apply(this, [].slice.call(arguments)); }; function show_file_list(data) { $('.folder_list').empty(); if (data.count > 0 || data.fileListSize > 0) { $('.show_file_list_btn').fadeIn(); } else { $('.show_file_list_btn').fadeOut(); } $.each(data.folderList, function (index, item) { $('.show_file_list .folder_list').append('<li><a class="show_folder" href="#file_id" data-id="' + item.id + '" title="进入文件夹:' + item.name + '"><span>' + item.name + '</span></a></li>'); }); $.each(data.fileList, function (index, item) { $('.show_file_list .folder_list').append('<li><a class="show_file file_' + item.id + '" href="#folder_id" data-id="' + item.id + '" title="点击获取:' + item.name + '"><span>' + item.name + '</span> <i>' + conver(item.size) + '</i></a></li>'); }); $('.show_folder').off('click').on('click', function (e) { e.preventDefault(); unsafeWindow.location.href = '/web/main/file/folder/' + $(this).data('id'); }); $('.show_file').off('click').on('click', function (e) { e.preventDefault(); $('#file_direct_link').empty(); var that = $(this); $.ajax({ url: '/api/open/file/getFileDownloadUrl.action', data: { fileId: $(this).data('id'), dt: 1, shareId: share_id }, dataType: 'xml', success: function (data) { var fileName = that.find('span').text(); var fileDownloadUrl = $(data).find('fileDownloadUrl').text() + '&fileName=' + encodeURIComponent(fileName); $('#file_direct_link').html('<b>直链网址:</b><a href="' + fileDownloadUrl + '" target="_blank" title="点击下载:' + fileName + '">' + fileDownloadUrl + '</a>'); } }); }); } 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; }