Greasy Fork

来自缓存

Greasy Fork is available in English.

北师大云盘下载器

解除下载限制,通过调用预览接口,清晰度稍有下降。

当前为 2020-06-16 提交的版本,查看 最新版本

// ==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/[email protected]/dist/jquery.min.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/toastr.min.js
// @resource toastr_css https://cdn.jsdelivr.net/npm/[email protected]/build/toastr.min.css
// ==/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('下载器初始化成功。');
})();