自动考试

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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 });