Greasy Fork is available in English.

青岛专业技术人员继续教育过验证

弹窗检查自动确认 ,过验证

// ==UserScript==
// @name         青岛专业技术人员继续教育过验证
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  弹窗检查自动确认 ,过验证
// @author       hat12
// @license      MIT
// @match        https://www.qdjxjy.com.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function delay(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    async function checkDialog() {
        try {

            const dialog = document.querySelector('.el-message-box');
            if (dialog) {
                const confirmBtn = Array.from(dialog.querySelectorAll('button')).find(btn => btn.textContent.trim() === '确定');
                if (confirmBtn) {
                    confirmBtn.click();
                    console.log("成功关闭弹窗。");
                } else {
                    console.log("未找到确定按钮。");
                }
            } else {
                console.log("未找到弹窗。");
            }

            await delay(3000);  // 等待3秒
 // Adding the floating window
            const floatingWindow = document.createElement('div');
            floatingWindow.style.position = 'fixed';
            floatingWindow.style.right = '10px'; // Adjust as needed
            floatingWindow.style.top = '100px'; // Adjust as needed
            floatingWindow.style.width = '180px';
            floatingWindow.style.height = '240px';
            floatingWindow.style.background = 'rgba(0, 0, 0, 0.6)';
            floatingWindow.style.borderRadius = '10px';
            floatingWindow.style.zIndex = '9999';
            floatingWindow.style.display = 'flex';
            floatingWindow.style.flexDirection = 'column';
            floatingWindow.style.alignItems = 'center';
            floatingWindow.style.justifyContent = 'center';

            const image = document.createElement('img');
            image.src = 'https://img.picgo.net/2024/05/29/1716973684846ff265a96759568cb.png ';
            image.style.maxWidth = '100%';
            image.style.maxHeight = '100%';
            image.style.borderRadius = '10px';
            floatingWindow.appendChild(image);

            const text = document.createElement('div');
            text.textContent = '需要帮忙加微';
            text.style.color = '#333333';
            text.style.fontSize = '15px';
            text.style.marginTop = '20px';
            floatingWindow.appendChild(text);

            document.body.appendChild(floatingWindow);
            // 播放视频
            try {
                const videoElement = document.querySelector("video");
                if (videoElement) {
                    videoElement.play();
                    console.log("成功开始播放视频。");
                } else {
                    console.log("未找到视频元素。");
                }
            } catch (e) {
                console.log("播放视频失败: ", e);
            }

            await delay(3000);  // 等待3秒


            const dialogWrapper = document.querySelector('.el-dialog__wrapper');
            if (dialogWrapper) {
                const dialogTitle = dialogWrapper.querySelector('.el-dialog__title');
                if (dialogTitle && dialogTitle.textContent.trim() === '学习验证') {
                    // 查找是否有“输入错误,请重新输入”的文字
                    const hasErrorText = Array.from(dialogWrapper.querySelectorAll('div')).some(div => {
                        return div.textContent.includes('输入错误,请重新输入');
                    });

                    if (hasErrorText) {
                        // 如果有错误,刷新页面
                        console.log("检测到‘输入错误,请重新输入’,刷新页面。");
                        location.reload();
                    } else {
                        // 如果没有错误,点击“确认”按钮
                        const confirmBtn = dialogWrapper.querySelector('button.el-button--primary');
                        if (confirmBtn) {
                            confirmBtn.click();
                            console.log("成功点击‘确认’按钮。");
                        } else {
                            console.log("未找到‘确认’按钮。");
                        }
                    }
                } else {
                    console.log("弹窗标题不是‘学习验证’。");
                }
            } else {
                console.log("未检测到弹窗。");
            }
        } catch (e) {
            console.log("检测弹窗失败: ", e);
        }
    }

    // 无限循环执行
    setInterval(checkDialog, 6000);  // 每6秒执行一次
})();