// ==UserScript== // @name 北师大云盘下载器 // @namespace https://zhangnew.com/ // @version 0.1 // @description 解除下载限制,通过调用预览接口,清晰度稍有下降。 // @author zhangnew // @match https://pan.bnu.edu.cn/link/view/* // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant GM_getResourceText // @grant GM_download // @require https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js // @require https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js // @resource toastr_css https://cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.css // @downloadURL none // ==/UserScript== GM_addStyle(GM_getResourceText('toastr_css')); toastr.options.timeOut = 5000; (function() { 'use strict'; const uuid = window.location.pathname.split("/")[3]; var meta_url = "https://pan.bnu.edu.cn/v2/delivery/metadata/" + uuid; var meta; // 所有视频信息 GM_xmlhttpRequest({ method: "GET", url: meta_url, onload: function(response) { meta = JSON.parse(response.responseText); console.log(meta.updator + " " + meta.path); } }); setTimeout( function loading() { var len = $('.list-item').length; if (len > 0){ toastr.success('发现 ' + len + '条视频, 下载器已激活.'); if($('.cmd-download').is(':visible')){ return; } console.log("data loaded."); let $ico_d = $('.cmd-download'); $ico_d.show(); $ico_d.toggleClass('cmd-download cmd-download-unbind'); // 取消原来的下载功能 let $btn_d = $('.i-download'); $btn_d.click(function(event) { // 视频标题 var title = event.target.parentNode.parentNode.parentElement.getElementsByClassName('display-name')[0].text meta.content.forEach(item => { if(item.path.split('/')[2] === title){ console.log("click " + item.path); GM_download(item.preview_url, title); toastr.success('开始下载:' + title); } }); }); } else { // wait a moment and check again setTimeout( loading , 500); } } , 500); console.log('下载器初始化成功。'); })();