// ==UserScript== // @name 成学课堂3.0 // @namespace http://tampermonkey.net/ // @version 3.1 // @description 成学课堂自动化控制面板,支持全自动视频控制、自动答题、自动提交作业等功能 // @author YourName // @match *://*.cx-online.net/* // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; // 检查是否已经注入了控制面板 if (window.autoControlPanelInjected) { return; } window.autoControlPanelInjected = true; // 创建并注入CSS样式 const style = document.createElement('style'); style.textContent = ` .auto-control-panel { position: fixed; top: 20px; right: 20px; width: 380px; background: white; border-radius: 12px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); z-index: 10000; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; overflow: hidden; border: 1px solid #e1e5e9; } .panel-header { background: linear-gradient(135deg, #1E4EE7, #3A7BFF); color: white; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; cursor: move; } .panel-title { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; } .panel-controls { display: flex; gap: 8px; } .panel-btn { background: rgba(255, 255, 255, 0.2); border: none; color: white; width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; } .panel-btn:hover { background: rgba(255, 255, 255, 0.3); } .panel-body { padding: 16px; max-height: 500px; overflow-y: auto; } .status-section { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f0f0f0; } .section-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #333; display: flex; align-items: center; gap: 6px; } .status-item { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; } .status-label { color: #666; } .status-value { font-weight: 500; color: #333; } .status-value.active { color: #1E4EE7; } .status-value.completed { color: #00a854; } .status-value.error { color: #f5222d; } .controls-section { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; } .control-btn { flex: 1; min-width: 150px; padding: 8px 12px; background: #f5f7fa; border: 1px solid #e1e5e9; border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; } .control-btn:hover { background: #ebf0f5; } .control-btn.primary { background: #1E4EE7; color: white; border-color: #1E4EE7; } .control-btn.primary:hover { background: #3A7BFF; } .control-btn.danger { background: #f5222d; color: white; border-color: #f5222d; } .control-btn.danger:hover { background: #ff4d4f; } .control-btn.success { background: #00a854; color: white; border-color: #00a854; } .control-btn.success:hover { background: #00c853; } .control-btn.warning { background: #fa8c16; color: white; border-color: #fa8c16; } .control-btn.warning:hover { background: #ffa940; } .control-btn.info { background: #1890ff; color: white; border-color: #1890ff; } .control-btn.info:hover { background: #40a9ff; } .progress-section { margin-top: 16px; } .progress-bar { height: 6px; background: #f0f0f0; border-radius: 3px; overflow: hidden; margin-bottom: 8px; } .progress-fill { height: 100%; background: linear-gradient(90deg, #1E4EE7, #3A7BFF); border-radius: 3px; transition: width 0.3s ease; } .progress-text { font-size: 12px; color: #666; text-align: center; } .log-section { margin-top: 16px; max-height: 120px; overflow-y: auto; border: 1px solid #f0f0f0; border-radius: 6px; padding: 8px; background: #fafafa; } .log-entry { font-size: 12px; margin-bottom: 4px; padding: 4px; border-radius: 3px; background: white; } .log-time { color: #999; margin-right: 6px; } .log-info { color: #1890ff; } .log-success { color: #00a854; } .log-warning { color: #fa8c16; } .log-error { color: #f5222d; } .minimized .panel-body { display: none; } .minimized { width: 200px; } .platform-indicator { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; } .platform-pc { background: #52c41a; } .platform-mobile { background: #1890ff; } .auto-mode-section { background: #f0f7ff; border-radius: 8px; padding: 12px; margin-bottom: 16px; border: 1px solid #d1e9ff; } @media (max-width: 768px) { .auto-control-panel { width: 340px; right: 10px; top: 10px; } } `; document.head.appendChild(style); // 创建控制面板HTML const panelHTML = `
成学课堂自动化控制 v3.1
🤖 全自动模式
🔍 系统状态
自动化状态: 未启动
平台检测: 检测中...
视频识别: 等待中
播放状态: 等待中
答题状态: 未检测
当前任务: 检测中...
弹窗状态: 未检测
📊 学习进度
等待检测进度...
${getCurrentTime()} 控制面板初始化完成
`; // 全局变量 let isFullAutoMode = false; let autoCheckInterval = null; // 使用更可靠的方法注入控制面板 function injectControlPanel() { if (document.getElementById('autoControlPanel')) { return; } const tempDiv = document.createElement('div'); tempDiv.innerHTML = panelHTML; const panel = tempDiv.firstElementChild; document.body.appendChild(panel); // 初始化面板功能 initPanelFunctionality(); console.log('成学课堂控制面板已成功注入'); } // 初始化面板功能 function initPanelFunctionality() { const panel = document.getElementById('autoControlPanel'); const panelHeader = document.getElementById('panelHeader'); const minimizeBtn = document.getElementById('minimizeBtn'); const closeBtn = document.getElementById('closeBtn'); const fullAutoBtn = document.getElementById('fullAutoBtn'); const stopAutoBtn = document.getElementById('stopAutoBtn'); const startAutoBtn = document.getElementById('startAutoBtn'); const pauseBtn = document.getElementById('pauseBtn'); const jumpToEndBtn = document.getElementById('jumpToEndBtn'); const nextSectionBtn = document.getElementById('nextSectionBtn'); const startAutoAnswerBtn = document.getElementById('startAutoAnswerBtn'); const submitHomeworkBtn = document.getElementById('submitHomeworkBtn'); // 平台检测 detectPlatform(); // 拖拽功能 let isDragging = false; let dragOffset = { x: 0, y: 0 }; panelHeader.addEventListener('mousedown', function(e) { isDragging = true; dragOffset.x = e.clientX - panel.getBoundingClientRect().left; dragOffset.y = e.clientY - panel.getBoundingClientRect().top; panel.style.cursor = 'grabbing'; }); document.addEventListener('mousemove', function(e) { if (!isDragging) return; const x = e.clientX - dragOffset.x; const y = e.clientY - dragOffset.y; const maxX = window.innerWidth - panel.offsetWidth; const maxY = window.innerHeight - panel.offsetHeight; panel.style.left = Math.max(0, Math.min(x, maxX)) + 'px'; panel.style.top = Math.max(0, Math.min(y, maxY)) + 'px'; panel.style.right = 'auto'; }); document.addEventListener('mouseup', function() { isDragging = false; panel.style.cursor = ''; }); // 控制按钮功能 minimizeBtn.addEventListener('click', function() { panel.classList.toggle('minimized'); minimizeBtn.textContent = panel.classList.contains('minimized') ? '+' : '−'; }); closeBtn.addEventListener('click', function() { if (confirm('确定要关闭控制面板吗?')) { panel.style.display = 'none'; stopFullAutoMode(); } }); // 全自动模式 fullAutoBtn.addEventListener('click', function() { startFullAutoMode(); }); stopAutoBtn.addEventListener('click', function() { stopFullAutoMode(); }); let isAutomationRunning = false; startAutoBtn.addEventListener('click', function() { if (!isAutomationRunning) { isAutomationRunning = true; startAutoBtn.innerHTML = '⏹️ 停止播放'; startAutoBtn.classList.add('danger'); document.getElementById('playbackStatus').textContent = '播放中'; document.getElementById('playbackStatus').className = 'status-value active'; addLog('开始播放视频', 'success'); startRealAutomation(); } else { isAutomationRunning = false; startAutoBtn.innerHTML = '▶️ 开始播放'; startAutoBtn.classList.remove('danger'); document.getElementById('playbackStatus').textContent = '已停止'; document.getElementById('playbackStatus').className = 'status-value'; addLog('停止播放', 'warning'); } }); pauseBtn.addEventListener('click', function() { if (isAutomationRunning) { addLog('暂停播放', 'warning'); document.getElementById('playbackStatus').textContent = '已暂停'; // 暂停视频 const videos = document.querySelectorAll('video'); if (videos.length > 0) { videos[0].pause(); } } else { addLog('继续播放', 'info'); document.getElementById('playbackStatus').textContent = '播放中'; // 继续播放视频 const videos = document.querySelectorAll('video'); if (videos.length > 0) { videos[0].play(); } } }); // 跳转到视频结尾功能 jumpToEndBtn.addEventListener('click', function() { addLog('尝试跳转到视频结尾', 'info'); jumpVideoToEnd(); }); // 观看下节视频功能 nextSectionBtn.addEventListener('click', function() { addLog('尝试点击"观看下节视频"按钮', 'info'); clickNextSectionButton(); }); // 自动答题功能 startAutoAnswerBtn.addEventListener('click', function() { addLog('开始自动答题', 'info'); document.getElementById('answerStatus').textContent = '答题中'; document.getElementById('answerStatus').className = 'status-value active'; autoAnswer(); }); // 提交作业功能 submitHomeworkBtn.addEventListener('click', function() { addLog('尝试提交作业', 'info'); submitHomework(); }); // 开始检测页面元素 setTimeout(() => { detectVideoElements(); detectCurrentTask(); detectLearningProgress(); // 开始检测弹窗 startPopupDetection(); // 检测答题页面 checkAnswerPage(); }, 1000); } // 工具函数 function getCurrentTime() { const now = new Date(); return `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`; } function addLog(message, type = 'info') { const logSection = document.getElementById('logSection'); if (!logSection) return; const logEntry = document.createElement('div'); logEntry.className = 'log-entry'; logEntry.innerHTML = `${getCurrentTime()} ${message}`; logSection.appendChild(logEntry); logSection.scrollTop = logSection.scrollHeight; if (logSection.children.length > 20) { logSection.removeChild(logSection.firstChild); } } function detectPlatform() { const platformIndicator = document.getElementById('platformIndicator'); const platformStatus = document.getElementById('platformStatus'); if (!platformIndicator || !platformStatus) return; const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); if (isMobile) { platformIndicator.className = 'platform-indicator platform-mobile'; platformStatus.textContent = '移动端'; addLog('检测到移动端平台', 'info'); } else { platformIndicator.className = 'platform-indicator platform-pc'; platformStatus.textContent = 'PC端'; addLog('检测到PC端平台', 'info'); } } function detectVideoElements() { const videoDetectionStatus = document.getElementById('videoDetectionStatus'); if (!videoDetectionStatus) return; const videos = document.querySelectorAll('video'); if (videos.length > 0) { videoDetectionStatus.textContent = '已找到视频'; videoDetectionStatus.className = 'status-value completed'; addLog(`找到 ${videos.length} 个视频元素`, 'success'); initVideoEventListeners(videos); } else { videoDetectionStatus.textContent = '未找到视频'; videoDetectionStatus.className = 'status-value error'; addLog('未找到视频元素', 'warning'); } } function detectCurrentTask() { const currentTaskElement = document.getElementById('currentTask'); if (!currentTaskElement) return; const taskElements = document.querySelectorAll('.videoItemName'); if (taskElements.length > 0) { let currentTask = '未知任务'; for (let element of taskElements) { if (element.classList.contains('activeClass') || element.parentElement.querySelector('.isAutoplay')) { currentTask = element.textContent.trim(); break; } } currentTaskElement.textContent = currentTask; addLog(`检测到当前任务: ${currentTask}`, 'info'); } } function detectLearningProgress() { const progressFill = document.getElementById('progressFill'); const progressText = document.getElementById('progressText'); if (!progressFill || !progressText) return; const videoItems = document.querySelectorAll('.videoItem'); if (videoItems.length > 0) { let completed = 0; let total = videoItems.length; for (let item of videoItems) { if (item.querySelector('.lastMark') || item.querySelector('.isAutoplay[src*="gif"]')) { completed++; } } const percentage = Math.round((completed / total) * 100); progressFill.style.width = `${percentage}%`; progressText.textContent = `已完成 ${completed}/${total} 个任务 (${percentage}%)`; addLog(`学习进度: ${completed}/${total} (${percentage}%)`, 'info'); } } function initVideoEventListeners(videos) { videos.forEach((video, index) => { video.addEventListener('play', function() { addLog(`视频 ${index + 1} 开始播放`, 'info'); document.getElementById('playbackStatus').textContent = '播放中'; document.getElementById('playbackStatus').className = 'status-value active'; }); video.addEventListener('pause', function() { addLog(`视频 ${index + 1} 已暂停`, 'warning'); document.getElementById('playbackStatus').textContent = '已暂停'; }); video.addEventListener('ended', function() { addLog(`视频 ${index + 1} 播放完成`, 'success'); // 在全自动模式下,视频结束后自动处理下一步 if (isFullAutoMode) { setTimeout(() => { handleVideoEndAutomation(); }, 2000); } }); // 监听时间更新,用于显示视频进度 video.addEventListener('timeupdate', function() { updateVideoProgress(video); }); }); } // 更新视频进度显示 function updateVideoProgress(video) { if (!video.duration) return; const progress = (video.currentTime / video.duration) * 100; // 可以在这里添加进度显示,如果需要的话 } // 跳转到视频结尾功能 function jumpVideoToEnd() { const videos = document.querySelectorAll('video'); if (videos.length > 0) { const video = videos[0]; if (video.duration && video.duration > 0) { // 设置当前时间为视频总时长减1秒,确保能触发ended事件 video.currentTime = Math.max(0, video.duration - 1); addLog('已跳转到视频结尾', 'success'); // 如果视频已暂停,则播放一下以确保触发结束事件 if (video.paused) { video.play().then(() => { setTimeout(() => { video.pause(); }, 500); }); } } else { addLog('无法获取视频时长,无法跳转到结尾', 'error'); } } else { addLog('未找到视频', 'error'); } } // 检测并点击"观看下节视频"按钮 function clickNextSectionButton() { // 查找包含"观看下节视频"文本的元素 const nextSectionButtons = document.querySelectorAll('span, button, a, div'); let foundButton = null; for (let element of nextSectionButtons) { if (element.textContent && element.textContent.trim() === '观看下节视频') { foundButton = element; break; } } if (foundButton) { foundButton.click(); addLog('已点击"观看下节视频"按钮', 'success'); document.getElementById('popupStatus').textContent = '已处理'; document.getElementById('popupStatus').className = 'status-value completed'; // 更新当前任务 setTimeout(() => { detectCurrentTask(); detectLearningProgress(); }, 1000); return true; } else { addLog('未找到"观看下节视频"按钮', 'warning'); document.getElementById('popupStatus').textContent = '未找到按钮'; document.getElementById('popupStatus').className = 'status-value error'; return false; } } // 检测弹窗 function startPopupDetection() { // 定期检查是否有"观看下节视频"弹窗出现 const popupCheckInterval = setInterval(() => { const nextSectionButtons = document.querySelectorAll('span, button, a, div'); let foundPopup = false; for (let element of nextSectionButtons) { if (element.textContent && element.textContent.trim() === '观看下节视频') { foundPopup = true; break; } } if (foundPopup) { document.getElementById('popupStatus').textContent = '检测到弹窗'; document.getElementById('popupStatus').className = 'status-value active'; // 如果自动化运行中,自动点击 if (isFullAutoMode) { addLog('检测到弹窗,自动点击"观看下节视频"', 'info'); if (clickNextSectionButton()) { clearInterval(popupCheckInterval); } } } else { document.getElementById('popupStatus').textContent = '未检测到弹窗'; document.getElementById('popupStatus').className = 'status-value'; } }, 2000); // 10分钟后停止检测 setTimeout(() => { clearInterval(popupCheckInterval); }, 600000); } function startRealAutomation() { addLog('开始播放视频...', 'info'); const videos = document.querySelectorAll('video'); if (videos.length > 0) { videos[0].play().then(() => { addLog('视频开始播放', 'success'); }).catch(e => { addLog(`自动播放失败: ${e.message}`, 'error'); const playButton = document.querySelector('.xgplayer-play, [title*="播放"], .fa-play'); if (playButton) { playButton.click(); addLog('已通过点击播放按钮开始播放', 'info'); } }); } else { addLog('未找到可播放的视频', 'error'); } } // 自动答题功能 function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // 获取当前显示的题目容器 function getCurrentQuestion() { const items = document.querySelectorAll('.homeWork_cxt--left_item'); for (let item of items) { if (item.style.display !== 'none' && item.querySelector('.multiple')) { return item; } } return null; } // 解析答案 function parseAnswer(questionContainer) { // 先尝试从解析中获取答案 let analysisDiv = questionContainer.querySelector('.multiple_ctx--analysis div:nth-child(2)'); if (analysisDiv) { let analysisText = analysisDiv.textContent; // 提取/**/中的内容作为答案关键词 let match = analysisText.match(/\/\*(.*?)\*\//); if (match) { return match[1]; } } // 如果没有找到,尝试从正确答案区域获取 let rightAnsSpan = questionContainer.querySelector('.multiple_ctx--rightAns span'); if (rightAnsSpan) { return rightAnsSpan.textContent.trim(); } return null; } // 判断题型 function getQuestionType(questionContainer) { let typeDiv = questionContainer.querySelector('.multiple_head--queType'); if (typeDiv) { let typeText = typeDiv.textContent.trim(); if (typeText.includes('多项选择题') || typeText.includes('多选')) { return 'multiple'; } else if (typeText.includes('判断题')) { return 'judge'; } else { return 'single'; } } return 'single'; } // 选择答案 async function selectAnswer(questionContainer) { let answer = parseAnswer(questionContainer); if (!answer) { addLog('❌ 未找到答案', 'error'); return false; } addLog('✅ 找到答案:' + answer, 'success'); let questionType = getQuestionType(questionContainer); let options = questionContainer.querySelectorAll('.multiple_ctx--option'); // 根据题型和答案选择选项 if (questionType === 'single') { // 单选题 for (let option of options) { let optionText = option.querySelector('.multiple_ctx--option_title').textContent.trim(); // 检查答案是否是选项字母 if (answer.length <= 2 && optionText.startsWith(answer + '、')) { option.click(); addLog('👉 选择了选项:' + optionText, 'info'); break; } // 检查答案是否包含在选项文本中 if (optionText.includes(answer) || answer.includes(optionText.substring(2))) { option.click(); addLog('👉 选择了选项:' + optionText, 'info'); break; } } } else if (questionType === 'multiple') { // 多选题 let answers = answer.split(/[、,,]/); addLog('📋 多选答案:' + answers, 'info'); for (let ans of answers) { ans = ans.trim(); for (let option of options) { let optionText = option.querySelector('.multiple_ctx--option_title').textContent.trim(); if (ans.length <= 2 && optionText.startsWith(ans)) { option.click(); addLog('👉 选择了选项:' + optionText, 'info'); } else if (ans.includes(optionText.substring(2)) || optionText.includes(ans)) { option.click(); addLog('👉 选择了选项:' + optionText, 'info'); } } } } else if (questionType === 'judge') { // 判断题 if (answer.includes('正确') || answer.includes('对') || answer === 'A') { options[0].click(); addLog('👉 选择了:正确', 'info'); } else { options[1].click(); addLog('👉 选择了:错误', 'info'); } } return true; } // 点击确认答案按钮 async function confirmAnswer(questionContainer) { let confirmBtn = questionContainer.querySelector('.multiple_ctx--tips button.el-button--primary'); if (confirmBtn && confirmBtn.textContent.includes('确认答案')) { confirmBtn.click(); addLog('📌 已确认答案', 'info'); await delay(500); return true; } return false; } // 点击下一题按钮 async function nextQuestion(questionContainer) { let nextBtn = questionContainer.querySelector('.multiple_bottom button.el-button--primary:last-child'); if (nextBtn && nextBtn.textContent.includes('下一题') && !nextBtn.disabled) { nextBtn.click(); addLog('➡️ 进入下一题', 'info'); await delay(1000); return true; } return false; } // 检查页面是否包含题目元素 function checkAnswerPage() { const hasQuestions = document.querySelector('.homeWork_cxt--left_item') || document.querySelector('.multiple') || document.querySelector('.multiple_ctx'); if (hasQuestions) { document.getElementById('answerStatus').textContent = '检测到题目'; document.getElementById('answerStatus').className = 'status-value completed'; addLog('✅ 检测到答题页面', 'success'); return true; } else { document.getElementById('answerStatus').textContent = '未检测到题目'; document.getElementById('answerStatus').className = 'status-value'; return false; } } // 提交作业功能 function submitHomework() { // 查找提交作业按钮 const submitButtons = document.querySelectorAll('button.el-button--primary.el-button--large'); let foundSubmitBtn = null; for (let button of submitButtons) { if (button.textContent && button.textContent.trim() === '提交作业') { foundSubmitBtn = button; break; } } if (foundSubmitBtn) { foundSubmitBtn.click(); addLog('✅ 已点击提交作业按钮', 'success'); return true; } else { addLog('❌ 未找到提交作业按钮', 'error'); return false; } } // 主函数 - 自动答题流程 async function autoAnswer() { addLog('🚀 开始自动答题...', 'info'); let maxAttempts = 50; let attempts = 0; let successCount = 0; while (attempts < maxAttempts) { attempts++; // 获取当前题目 let currentQuestion = getCurrentQuestion(); if (!currentQuestion) { addLog('📭 未找到题目', 'warning'); break; } addLog(`📝 正在处理第 ${attempts} 题...`, 'info'); // 选择答案 let selected = await selectAnswer(currentQuestion); if (selected) successCount++; await delay(500); // 确认答案 await confirmAnswer(currentQuestion); await delay(500); // 尝试进入下一题 let hasNext = await nextQuestion(currentQuestion); if (!hasNext) { addLog('🏁 没有更多题目了', 'info'); // 答题完成后自动提交作业 if (isFullAutoMode) { setTimeout(() => { submitHomework(); }, 1000); } break; } await delay(1000); } addLog(`✨ 自动答题完成!共答题 ${successCount} 题`, 'success'); document.getElementById('answerStatus').textContent = '答题完成'; document.getElementById('answerStatus').className = 'status-value completed'; } // 全自动模式功能 function startFullAutoMode() { if (isFullAutoMode) return; isFullAutoMode = true; document.getElementById('autoStatus').textContent = '全自动运行中'; document.getElementById('autoStatus').className = 'status-value active'; addLog('🚀 启动全自动学习模式', 'success'); // 开始自动化检测循环 autoCheckInterval = setInterval(() => { checkPageStateAndAutoProcess(); }, 3000); // 立即执行一次检查 checkPageStateAndAutoProcess(); } function stopFullAutoMode() { if (!isFullAutoMode) return; isFullAutoMode = false; document.getElementById('autoStatus').textContent = '已停止'; document.getElementById('autoStatus').className = 'status-value'; if (autoCheckInterval) { clearInterval(autoCheckInterval); autoCheckInterval = null; } addLog('⏹️ 停止全自动学习模式', 'warning'); } // 检测页面状态并自动处理 function checkPageStateAndAutoProcess() { if (!isFullAutoMode) return; // 1. 检查是否有视频需要播放 const videos = document.querySelectorAll('video'); if (videos.length > 0 && videos[0].paused) { addLog('检测到暂停的视频,开始播放', 'info'); videos[0].play().catch(e => { addLog(`自动播放失败: ${e.message}`, 'error'); }); } // 2. 检查是否有"观看下节视频"弹窗 const nextSectionButtons = document.querySelectorAll('span, button, a, div'); for (let element of nextSectionButtons) { if (element.textContent && element.textContent.trim() === '观看下节视频') { addLog('检测到弹窗,自动点击"观看下节视频"', 'info'); element.click(); break; } } // 3. 检查是否有答题页面 if (checkAnswerPage()) { addLog('检测到答题页面,开始自动答题', 'info'); autoAnswer(); } // 4. 检查是否可以提交作业 const submitButtons = document.querySelectorAll('button.el-button--primary.el-button--large'); for (let button of submitButtons) { if (button.textContent && button.textContent.trim() === '提交作业') { addLog('检测到可提交作业,自动提交', 'info'); button.click(); break; } } } // 视频结束后的自动化处理 function handleVideoEndAutomation() { if (!isFullAutoMode) return; addLog('视频播放完成,自动处理下一步', 'info'); // 1. 先尝试处理弹窗 const nextSectionButtons = document.querySelectorAll('span, button, a, div'); let handledPopup = false; for (let element of nextSectionButtons) { if (element.textContent && element.textContent.trim() === '观看下节视频') { element.click(); addLog('自动点击"观看下节视频"按钮', 'success'); handledPopup = true; break; } } // 2. 如果没有弹窗,检查是否有答题 if (!handledPopup) { setTimeout(() => { if (checkAnswerPage()) { addLog('开始自动答题流程', 'info'); autoAnswer(); } }, 1000); } } // 使用多种方式确保控制面板被注入 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', injectControlPanel); } else { injectControlPanel(); } // 备用注入方法 setTimeout(injectControlPanel, 1000); setTimeout(injectControlPanel, 3000); })();