教评助手

Automate certain actions on a webpage with a stylish button trigger

2024/12/17のページです。最新版はこちら。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name         教评助手
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Automate certain actions on a webpage with a stylish button trigger
// @author       Bailu
// @match        https://my.gdip.edu.cn/EducationEvaluation/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 定义sleep函数
    async function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    // 定义example函数
    async function example(i) {
        let c = document.querySelectorAll(".table-item-action span:nth-child(2) button.el-button--text");
        for (let c1 of c) {
            let e=null;
            while(e){
            e = document.querySelector(".table-item-action span:nth-child(2) button.el-button--text");
            }
            e.click();
            await sleep(1000);
            if (document.querySelector(".player-video video")!= null) {
                document.querySelector(".el-checkbox span").click();
                document.querySelector(".player-video video").play();
                await sleep(3 * 1000);
                document.querySelector(".player-video video").currentTime = 180;
                await sleep(1000);
                document.querySelector("span .el-button--primary").click();
            }
            await sleep(1000);

            if (i == 0) {
                // 合格
                var a = document.querySelectorAll("label.el-radio:nth-child(2)");
            } else if (i == 1) {
                // 满分
                var a = document.querySelectorAll("label.el-radio:nth-child(1)");
            }
            await sleep(1000);
            a.forEach((e) => {
                e.click();
            });
            await sleep(1000);
            let b = document.querySelector("button.el-button--primary");
            b.click();
            await sleep(2000);
        }
    }

    // 创建并添加美化后的按钮
    function addButton() {
        const button = document.createElement('button');
        button.textContent = 'Run Automation';
        button.id = 'runAutomationButton';
        document.body.appendChild(button);

        // 添加CSS样式
        const style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = `
            #runAutomationButton {
                padding: 10px 20px;
                font-size: 16px;
                color: #fff;
                background-color: #007bff;
                border: none;
                border-radius: 5px;
                cursor: pointer;
                outline: none;
                position: fixed;
                top: 100px;
                right: 10px;
                z-index: 9999;
                transition: background-color 0.3s ease;
            }
            #runAutomationButton:hover {
                background-color: #0056b3;
            }
        `;
        document.head.appendChild(style);

        // 添加点击事件
        button.onclick = function() {
            example(0); // 假设默认为合格,可以根据需要修改
        };
    }

    // 页面加载完毕后添加按钮
    window.addEventListener('load', addButton);
})();