🥇湖南师范大学专业技术人员继续教育刷课【影刃】

湖南师范大学专业技术人员继续教育刷课

// ==UserScript==
// @name         🥇湖南师范大学专业技术人员继续教育刷课【影刃】
// @namespace    https://doc.yingren.xyz
// @version      1.0
// @description  湖南师范大学专业技术人员继续教育刷课
// @author       影刃
// @match        https://www.ejxjy.com/*
// @grant        none
// @license      GPL 3
// ==/UserScript==

(function() {
    'use strict';

    if (location.href.includes("myCourseDetail.html?courseId=")) {
        // 使用立即执行函数表达式 (IIFE) 来封装代码,避免污染全局命名空间
        (function() {
            const checkInterval = 5000; // 检查间隔时间(毫秒)
            const delayBeforeRedirect = 2000; // 点击按钮后延迟跳转时间(毫秒)
            function checkJboxContent() {
                const jboxContent = document.querySelector("#jbox-content");
                if (!jboxContent) {
                    return;
                }
                const contentText = jboxContent.innerText;
                // 检查是否包含特定文本
                if (contentText.includes("你已学习完该课时") || contentText.includes("问题")) {
                    const closeButton = document.querySelector(".jbox-button");
                    if (closeButton) {
                        closeButton.click();
                        // 延迟跳转
                        setTimeout(() => {
                            const index = location.href.indexOf("&columnId=");
                            let newHref = location.href;
                            if (index !== -1) {
                                newHref = location.href.substring(0, index);
                            }
                            location.href = newHref;
                        }, delayBeforeRedirect);
                    }
                }
            }
            // 设置定时器检查 #jbox-content 的内容
            setInterval(checkJboxContent, checkInterval);
        })();
    }

})();