qwercccv / chinalife_elearning_batch_assess

// ==UserScript==
// @name         chinalife_elearning_batch_assess
// @namespace    https://openuserjs.org/users/qwercccv
// @version      2024-10-21
// @description  auto assess chinalife elearning class
// @author       You
// @match        https://*.e-chinalife.com/els/learner-studentpc-fe/assessDetail?*
// @grant        none
// @copyright 2024, qwercccv (https://openuserjs.org/users/qwercccv)
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
        console.log("ok");
// 等待页面加载完成
/* window.onload = function() {
    console.log("ok1");
    // 找到所有 class 为 'el-radio__label' 且文本内容为 'A、优' 的 span
    const observer = new MutationObserver(function(mutations, obs) {
            const qrDiv = document.querySelector('.questionItem');

            if (qrDiv) {
                */
                setTimeout(function() {
    const labels = document.querySelectorAll('.el-radio__label');
    labels.forEach(label => {
        if (label.textContent.trim() === 'A、优' || label.textContent.trim() === '优') {
            // 获取当前 label 元素的父元素
            const parent = label.parentElement;
            // 在父元素中找到 class 为 'el-radio__input' 的 span 元素
            const input = parent.querySelector('.el-radio__input');
            if (input) {
                // 模拟点击事件
                input.click();
                window.scrollTo(0, 0);
            }
        }
    });
                    setTimeout(function() {
     const submitButtons = Array.from(document.querySelectorAll('div')).filter(div => div.textContent.trim() === '提交答案');
                submitButtons.forEach(submitButton => {
                        submitButton.click();
                });
                        setTimeout(function() {
                    window.close();
                    },600);
                    },600);
                },900);
    }
   /* });
    observer.observe(document, {
            childList: true,
            subtree: true
        });
}  }      */

    // Your code here...
)();