xtu评教

xtu教务系统自动评教

目前為 2020-12-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        xtu评教
// @namespace   http://tampermonkey.net/
// @match       http://jwxt.xtu.edu.cn/jsxsd/xspj/xspj_*
// @grant       none
// @version     1.0
// @author      D15h35
// @description xtu教务系统自动评教
// @require      https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js
// ==/UserScript==
var $ = window.jQuery;
window.confirm = function () { return true; }
window.alert = function () { return true; }

function closeWebPage() {
    if (navigator.userAgent.indexOf("MSIE") > 0) {//close IE
        if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
            window.opener = null;
            window.close();
        } else {
            window.open('', '_top');
            window.top.close();
        }
    }
    else if (navigator.userAgent.indexOf("Firefox") > 0) {//close firefox
        window.location.href = 'about:blank ';
    } else {//close chrome;It is effective when it is only one.
        window.opener = null;
        window.open('', '_self');
        window.close();
    }
}

if (location.pathname === "/jsxsd/xspj/xspj_list.do") {
    let pages = [];
    let appraise = $("a");
    let pageIndex = 0;

    if (appraise != null) {
        appraise.each(function (index, a) {
            if ($(a).text() === "评价") {
                pages.push($(a).attr('href').match(/'(\/[^\s]*)'/)[1]);
            }
        });
    }

    if (pages.length != 0) {
        let h = setInterval(() => {
            window.open(pages[pageIndex]);
            if (pageIndex >= pages.length - 1) {
                clearInterval(h);
            }
            pageIndex++;
        }, 2000);
    }
} else if (location.pathname === "/jsxsd/xspj/xspj_edit.do") {
    let tj = $("#tj");
    if (tj != null) {
        let radioNum = $("input[id^='pj0601id'][id$='_1']");
        for (let pageIndex = 1; pageIndex < radioNum.length; pageIndex++) {
            $("#pj0601id_" + pageIndex + "_" + [1, 2][Math.floor(Math.random() * 2)]).attr("checked", true);
        }
        tj.click();
        closeWebPage();
    }
}