ZJU Tronclass Helper

Download Tronclass Courseware

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         ZJU Tronclass Helper
// @namespace    ncj.wiki
// @version      2.3.5
// @license      MIT
// @description  Download Tronclass Courseware
// @author       NCJ
// @match        *://courses.zju.edu.cn/course/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js
// ==/UserScript==

function nice_comment() {
    var good_words = ['挺好的', '很不错', '技术上还可以完善一下', '挺棒的', '看好你们', '视频还有改进的空间', '点子很赞', '加油'];
    good_words.sort(() => Math.random() - 0.5);
    var cnt = Math.floor(Math.random() * (good_words.length - 1)) + 1;
    return good_words.slice(0, cnt).join(' ') + '!';
}

$(document).bind('DOMSubtreeModified', function() {
    if ($('#Tronclass_Downloader').length == 0 && $('#file-previewer-with-note > div > div > div.header.clearfix').length) {
        $('#file-previewer-with-note > div > div > div.header.clearfix').append('<input type="button" value="Download" id="Tronclass_Downloader">');
        $("#Tronclass_Downloader").css("position", "relative").css("left", 10);
        $('#Tronclass_Downloader').click(function(){
            window.open(decodeURIComponent(document.getElementById('pdf-viewer').src.split("?file=")[1]));
        });
    }

    if ($('#Tronclass_Downloader_video').length == 0 && $('video').length && $('video')[0].children.length == 3 && $('video')[0].children[0].getAttribute('src').indexOf('/api') == 0) {
        var v=$('video')[0];
        for (var i of v.children) {
            $(v.parentNode.parentNode).prepend(`<a href="${i.getAttribute('src')}" id="Tronclass_Downloader_video">\t${i.getAttribute('label')}\t</a>`);
        }
    }

    if ($('#Tronclass_Random_Nice_Comment').length == 0 && $('.comment').length) {
        $('#give-score > div > div.main-area > div.main-content > div.right-section > form > div.form-title.ng-scope').append('<input type="button" value="随机生成" id="Tronclass_Random_Nice_Comment">');
        $('#Tronclass_Random_Nice_Comment').click(function() {
            $('textarea').val(nice_comment());
            angular.element($('textarea')[1]).triggerHandler('input');
            $('input[name="score"]').val(Math.floor(Math.random() * (100 - 85))+ 85);
            angular.element($('input[name="score"]')).triggerHandler('change');
        });
    }
});