交大的课都是精品课,我除了感恩还能做什么呢

赞美太阳

// ==UserScript==
// @name         交大的课都是精品课,我除了感恩还能做什么呢
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  赞美太阳
// @author       Victrid
// @match        https://i.sjtu.edu.cn/xspjgl/*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAACPhJREFUWEfFl3mM1dUVx7/n3N/vzcIAI8x7Q2DezCBSVCLEMswMi7hFg7hExSVxqVZNWou1TZqa2jY10aRNGxNjtDYmtikVuxCtUWJjUYtxQWYcxaWWgbLMxgyzCgzM8t7vnm9zHx0LCMU2Tfr+/N3lfO653/O95wn+zz/5b+K3YFE8VnGoGBiZHJlpomUH8mXj+Qvb2sb+0/2+MMCWaWdMYTx2ljOtMaIcIomAk0g4KAZBiRV22CvbOIq/Lz3YNfRFYE4J8FbFvMkxxlYQnBsCqWdrAnajBEPjUcQQpCqK2Lt/fHpMPZOOs2AoUbGOZBzNpwI5KQABaanMzjcvyyjSqZBuo12lIuYNzy0ZbN929AmbKrJ1gNwA4DAEbRT2gDpXaE31A53vCVCAPf53QoAQvDmdXU7oAlH8qb23vaM2XXWJQecpuNUT5czxraNPtyVTs1rI2wCUC/DW4Un64KSDuTRdfCnI3rKByRvn45PcKQEKwTM1jYBVuny8qe7T3QfCoqaK6iu8WGt6anHn0P7RGnEua6SDoESp/TAfm7oKwBaC8lFjf8ezYV3LzJmllotuJniofqDzDwLY0RCfy0Dz9OxiqpxdrOPPLuztPTwx+Z0ZtbWa5+l0doGYLIDgbAJeAAGREOgR4SYBdlGi1oa+PR9OrN1cVVUSjblrKdbR0N/55kkBWmbOrPA5dyugO/IofqM4NezrurtHmtO1M8L9Q3GnAGUhxaQ0k9hd2EysVqiLIaxH4a75vDn32yX72trC8Nby2nIfscQLViWRvrqsZ0/7BMQxGWjK1FxD4jQhF1PQ6uheHkcyHIvcC8GVMLwhER5fvK9jW0hly2mnT9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xZoloFmGTnTAncEIy8tDhCNLjzfX8uxN/YQ2cCuZ/Nf4P8iTQXa0LxcMAAAAASUVORK5CYII=
// @grant        none
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';
    var pjfz = window.pjfz = {};

    pjfz.hqkc = function() {
        var t = 1;
        while($("#"+t).length==1){
            t+=1;
        }
        return t-1;
    };

    pjfz.xzpj = function () {
        $(".radio-pjf[data-dyf=\"95\"]").each( function (index, element) {
            element.checked = true;
        });
        var input_str = $("#xspy").val();
        const reg = /\[%teacher%\]/;
        input_str = input_str.replace(reg, $('#jsxm').html());
        $(".panel-body textarea").val(input_str);
        $("#btn_xspj_bc").data("enter", "1");
        $("#btn_xspj_bc").click();
    }

    pjfz.zdpj = async function () {
        var zdkc = pjfz.hqkc();
        for(var xzkc=1;xzkc<=zdkc;xzkc++){
            if($("#"+xzkc).is(':contains("提交")'))
                continue;
            $("#"+xzkc).click();
            while($("#ajaxForm1").length == 0){
                await new Promise(r => setTimeout(r, 1000));
            }
            pjfz.xzpj();
            while($("#btn_ok").length == 0){
                await new Promise(r => setTimeout(r, 1000));
            }
            $("#btn_ok").click();
            await new Promise(r => setTimeout(r, 1000));
        }
    };

    pjfz.tjdq = async function () {
            $("#btn_xspj_tj").data("enter", "1");
            $("#btn_xspj_tj").click();
    };

    pjfz.tjqb = async function () {
        var zdkc = pjfz.hqkc();
        for(var xzkc=1;xzkc<=zdkc;xzkc++){
            if($("#"+xzkc).is(':contains("未")'))
                continue;
            if($("#"+xzkc).is(':contains("提交")'))
                continue;
            $("#"+xzkc).click();
            var havetj = 5;
            while($("#btn_xspj_tj").length == 0 && havetj){
                await new Promise(r => setTimeout(r, 1000));
                havetj -= 1;
            }
            if (havetj){
                $("#btn_xspj_tj").data("enter", "1");
                $("#btn_xspj_tj").click();
                havetj = 5;
                while($("#btn_ok").length == 0 && havetj){
                    await new Promise(r => setTimeout(r, 1000));
                    havetj -= 1;
                }
                if(havetj) {
                    $("#btn_ok").click();
                    await new Promise(r => setTimeout(r, 1000));
                }
            }
        }
    };

    $("#pjzttts").css("margin-bottom","10px");

    $("#kc-head").append("<div class=\"panel-title\" style=\"padding: 10px; background: #D6EAF8; border: 1px solid #ccc; border-radius: 5px;\"> <center>"
                        + "<p>评教内容</p> <br/>"
                        + "可以使用[%teacher%]来替换老师名字"
                        + "<textarea class=\"form-control input-zgpj\" rows=\"4\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"\" "
                        + " maxlength=\"500\" placeholder=\"请至少输入0个字,至多输入500个字\" data-original-title=\"\" style=\"margin-top: 10px\" id=\"xspy\">"
                        + "课程质量很高,[%teacher%]老师授课富有激情。\</textarea> "
                        + "<div class=\"btn-group \" style=\"float: none; margin-top: 10px\">"
                        + "<button class=\"btn btn-default btn-default\" type=\"button\" onclick=\"pjfz.xzpj()\">评当前</button> "
                        + "<button class=\"btn btn-default btn-default\" type=\"button\" onclick=\"pjfz.zdpj()\">评全部</button> "
                        + "<button class=\"btn btn-default btn-default\" type=\"button\" onclick=\"pjfz.tjdq()\">提交当前</button> "
                        + "<button class=\"btn btn-default btn-default\" type=\"button\" onclick=\"pjfz.tjqb()\">提交全部</button> "
                        + "</div>"
                        + "</center> </div>")
})();