Greasy Fork

Greasy Fork is available in English.

SYNU 一键教务系统评价

自动填写教务系统评价并点击保存按钮

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @license MIT
// @name         SYNU 一键教务系统评价
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  自动填写教务系统评价并点击保存按钮
// @author       你的名字
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 确保脚本只在父页面中运行,避免在iframe中创建按钮
    if (window !== window.top) return; // 如果当前窗口是嵌套在iframe中,就直接退出

    // 检查按钮是否已经存在
    if (document.getElementById('myCustomButton')) return;

    // 创建按钮
    const button = document.createElement('button');
    button.id = 'myCustomButton';  // 给按钮添加一个唯一的id
    button.textContent = '执行操作';
    button.style.position = 'fixed';
    button.style.top = '10px';
    button.style.right = '10px';
    button.style.zIndex = '10000';
    button.style.backgroundColor = '#4CAF50';
    button.style.color = 'white';
    button.style.border = 'none';
    button.style.padding = '10px 20px';
    button.style.cursor = 'pointer';
    button.style.borderRadius = '5px';
    button.style.display = 'flex';
    button.style.alignItems = 'center';  // 垂直居中
    button.style.justifyContent = 'center';  // 水平居中
    button.style.fontSize = '16px';  // 调整字体大小

    // 将按钮添加到页面
    document.body.appendChild(button);

    // 按钮点击事件
    button.addEventListener('click', () => {
        try {
            // 操作iframe中的内容
            const iframe = document.getElementById("iframeautoheight");
            if (iframe && iframe.contentWindow) {
                const itable = iframe.contentWindow.document.getElementById("trPjs");
                const irows = itable.getElementsByTagName("select");
                for (let i = 0; i < irows.length; i++) {
                    if (i % 11 === 0) {
                        irows[i].value = "良好";
                    } else {
                        irows[i].value = "优秀";
                    }
                }

                // 找到并点击保存按钮(Button1)
                const button1 = iframe.contentWindow.document.getElementById('Button1');
                if (button1) {
                    button1.click();  // 模拟点击保存按钮
                } else {
                    console.error('未找到保存按钮');
                }
            } else {
                console.error('无法找到指定的iframe');
            }
        } catch (error) {
            console.error('执行过程中发生错误:', error);
        }
    });
})();