Greasy Fork

Greasy Fork is available in English.

自动考试

自动进入下一个章节在单元测试结束后

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         自动考试
// @namespace    genggongzi_cx
// @version      1.1
// @description  自动进入下一个章节在单元测试结束后
// @author       genggongzi
// @match        *://*.chaoxing.com/*
// @match        *://*.edu.cn/*
// @connect      api.gochati.cn
// @connect      up.gochati.cn
// @run-at       document-end
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @grant        GM_setClipboard
// @license      MIT
// @original-author qq:2621905853
// @original-license MIT
// ==/UserScript==


        // Function to check for the presence of the element and click "確認"
    function checkAndClickConfirm() {
        // Select the "確認" button by its ID
        const confirmButton = document.getElementById('okBtn');

        // Check if the button exists
        if (confirmButton) {
            console.log('确认按钮已找到,正在点击...');

            // Simulate a click event
            confirmButton.click();

            // Clear the interval to stop further checks
            clearInterval(intervalId);
        } else {
            console.log('确认按钮尚未出现,继续监听...');
        }
    }

// Function to check for the presence of the element and click "確認"
function checkAndClickConfirm1() {
    // Select the "確認" button using a more general selector
    const confirmButton = document.querySelector('.cx_alert-blue');

    // Check if the button exists
    if (confirmButton && confirmButton.textContent.includes('确认')) {
        console.log('确认按钮已找到,正在点击...');

        // Simulate a click event
        confirmButton.click();

        // Clear the interval to stop further checks
        clearInterval(intervalId);
    } else {
        console.log('确认按钮尚未出现,继续监听...');
    }
}

// Set an interval to check every 10 seconds
const intervalId1 = setInterval(checkAndClickConfirm1, 10000);

function checkAndClickConfirm2() {
    const confirmButton = document.querySelector('.cx_alert-blue');

    if (confirmButton && confirmButton.textContent.includes('确认')) {
        console.log('确认按钮已找到,强制触发点击...');

        // Manually create and dispatch a click event
        const event = new MouseEvent('click', { bubbles: true, cancelable: true });
        confirmButton.dispatchEvent(event);

        clearInterval(intervalId);
    } else {
        console.log('确认按钮尚未出现,继续监听...');
    }
}

const intervalId2 = setInterval(checkAndClickConfirm2, 10000);

const observer = new MutationObserver(() => {
    const confirmButton = document.querySelector('.cx_alert-blue');
    if (confirmButton && confirmButton.textContent.includes('确认')) {
        console.log('确认按钮已找到,正在点击...');
        confirmButton.click();
        observer.disconnect(); // 停止观察
    }
});

// 开始观察整个文档
observer.observe(document.body, { childList: true, subtree: true });