Greasy Fork

Greasy Fork is available in English.

Mutx163学习通自动评教

学习通自动评价,默认满分

当前为 2024-03-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Mutx163学习通自动评教
// @namespace    http://tampermonkey.net/
// @version      v1
// @description  学习通自动评价,默认满分
// @author       Mutx163
// @match        http://newes.chaoxing.com/pj/newesReception/*
// @icon         
// @license MIT
// @grant        none
// ==/UserScript==
//默认开启了自动提交,把不喜欢的话自动提交下面的那行代码注释掉即可

window.onload = function() {
    'use strict';

    setTimeout(() => {
        // 查找所有标记为5分的<input type="radio">元素并模拟点击
        const options = document.querySelectorAll('input.inputvalue.reselect[score="5.0"]');
        options.forEach(option => {
            const clickEvent = new MouseEvent('click', {
                bubbles: true,
                cancelable: true,
                view: window
            });
            option.dispatchEvent(clickEvent);
        });

        // 查找<textarea>元素并填入“无”
        const textarea = document.querySelector('textarea.blueTextarea');
        if (textarea) {
            textarea.value = '无';

            // 触发keyup事件以模拟用户输入
            const keyupEvent = new Event('keyup', {
                bubbles: true,
                cancelable: true
            });
            textarea.dispatchEvent(keyupEvent);
        }

        // 延迟点击提交按钮,确保前面的操作已完成
        setTimeout(() => {
            const submitButton = document.querySelector('a[onclick="save(2);"]');
            if (submitButton) {
                const clickEvent = new MouseEvent('click', {
                    bubbles: true,
                    cancelable: true,
                    view: window
                });
                submitButton.dispatchEvent(clickEvent);
                console.log('提交按钮已模拟点击。');

                // 延迟点击弹窗中的“确定”按钮,以确保弹窗已经出现
                setTimeout(() => {
                    const confirmButton = document.querySelector('.layui-layer-btn0');
                    if (confirmButton) {
                        const clickEvent = new MouseEvent('click', {
                            bubbles: true,
                            cancelable: true,
                            view: window
                        });
                        confirmButton.dispatchEvent(clickEvent);
                        console.log('弹窗中的“确定”按钮已模拟点击。');
                    } else {
                        console.log('弹窗中的“确定”按钮未找到。');
                    }
                }, 1000); // 根据弹窗出现的实际延迟调整这个时间
            } else {
                console.log('提交按钮未找到,需要手动提交或检查选择器。');
            }
        }, 500); // 延迟500毫秒以确保<textarea>的值被正确设置和处理
    }, 1000); // 延迟1秒执行,根据实际加载时间调整
};