Greasy Fork 支持简体中文。

一键打包下载国科大sep上的课件

一键打包下载国科大sep上的课件,不用一个个点了

// ==UserScript==
// @name         一键打包下载国科大sep上的课件
// @version      1.0
// @description  一键打包下载国科大sep上的课件,不用一个个点了
// @author       VnYzm
// @require      https://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
// @require      https://cdn.bootcss.com/jszip/3.2.2/jszip.min.js
// @require      https://cdn.bootcss.com/FileSaver.js/1.3.8/FileSaver.min.js
// @match        https://course.ucas.ac.cn/portal/site/*/tool/*
// @namespace    DownloadPPT
// @license      GPLv2
// ==/UserScript==

(function() {
    'use strict';
    $('button:contains("复制")').after(
        '<input type="button" value="下载" style="margin:0" class="btn btn-default">');
    $(':button').click(function () {
        let zip = new JSZip();
        let files = $('input[name="selectedMembers"]:checked');
        if (files.length == 0) return;
        $(':button').prop('disabled','disabled')
        files.each(function () {
            let a = $(this).parent().next().children().first(); 
            zip.file(
                a.next().find('.hidden-sm').text(),
                fetch(a.prop('href')).then(r => r.blob()));
        });
        zip.generateAsync({type:'blob'}).then(function(content) {
            saveAs(content, '课件.zip');
            $(':button').removeProp('disabled');
        });
    });
})();