// ==UserScript== // @name 2026广东省教师继续教育信息平台-师德师风 // @namespace http://tampermonkey.net/ // @version 3.9 // @description 只挂机刷视频,不做考核题! // @author Assistant // @match https://jsxx.gds.edu.cn/* // @grant none // ==/UserScript== (function() { 'use strict'; console.log('========================================'); console.log('公需课助手重复播放版已启动'); console.log('========================================'); // ============ 配置 ============ const CONFIG = { REPLAY_MINUTES: 1, // 重复播放的分钟数 REPLAY_SECONDS: 1 * 60, // 重复播放的秒数 REFRESH_MINUTES: 10, // 刷新间隔(分钟) REFRESH_SECONDS: 10 * 60, // 刷新间隔(秒) CHECK_INTERVAL: 1000, // 检查间隔(毫秒) }; // ============ 日志 ============ const log = { info: (msg) => console.log(`[公需课助手] ${msg}`), success: (msg) => console.log(`%c[公需课助手] ✅ ${msg}`, 'color: green; font-weight: bold'), warning: (msg) => console.log(`%c[公需课助手] ⚠️ ${msg}`, 'color: orange; font-weight: bold'), }; // ============ 状态控制 ============ let hasClickedNext = false; let replayCount = 0; let refreshCount = 0; let replayTimer = null; let refreshTimer = null; let statusElement = null; // ============ 创建状态显示 ============ function createStatusDisplay() { const existing = document.getElementById('study-status-display'); if (existing) existing.remove(); statusElement = document.createElement('div'); statusElement.id = 'study-status-display'; statusElement.textContent = '🟢 挂机学习中...|邓老AI编程制作'; statusElement.style.cssText = ` position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(200, 200, 200, 0.5); color: red; font-size: 24px; font-weight: bold; padding: 20px 40px; border-radius: 10px; z-index: 999999; text-align: center; pointer-events: none; box-shadow: 0 0 20px rgba(0,0,0,0.2); border: 2px solid rgba(255,0,0,0.3); `; document.body.appendChild(statusElement); } // ============ 更新状态 ============ function updateStatus(text, color = 'red') { if (statusElement) { statusElement.textContent = text; statusElement.style.color = color; } } // ============ 触发点击 ============ function triggerClick(element) { if (!element) return false; try { element.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window })); element.click(); return true; } catch(e) { return false; } } // ============ 核心:重复播放视频前5分钟 ============ function startReplayLoop() { if (replayTimer) clearInterval(replayTimer); replayCount = 0; log.success('开始重复播放视频前1分钟'); replayTimer = setInterval(() => { const video = document.querySelector('video'); if (!video) return; // 当视频播放到5分钟时,跳回开头 if (video.currentTime >= CONFIG.REPLAY_SECONDS) { replayCount++; log.success(`第 ${replayCount} 次重复播放`); // 更新状态时不显示重复次数 updateStatus('🟢 挂机学习中...|邓老AI编程制作', 'red'); video.currentTime = 0; video.play().catch(() => {}); } }, CONFIG.CHECK_INTERVAL); } // ============ 停止重复播放 ============ function stopReplayLoop() { if (replayTimer) { clearInterval(replayTimer); replayTimer = null; } } // ============ 刷新网页 ============ function refreshPage() { refreshCount++; log.success(`第 ${refreshCount} 次刷新网页`); updateStatus('🟡 正在刷新网页...|邓老AI编程制作', 'orange'); // 停止所有计时器 stopReplayLoop(); if (refreshTimer) { clearInterval(refreshTimer); refreshTimer = null; } // 延迟刷新 setTimeout(() => { log.info('正在刷新网页...|邓老AI编程制作'); location.reload(); }, 2000); } // ============ 开始刷新计时 ============ function startRefreshTimer() { if (refreshTimer) clearInterval(refreshTimer); log.info(`开始刷新计时,每 ${CONFIG.REFRESH_MINUTES} 分钟刷新一次`); refreshTimer = setInterval(() => { // 检查是否有完成弹窗,如果有就不刷新 const popupLayer = document.querySelector('.mylayer-layer.mylayer-openBtns'); if (popupLayer) { const style = window.getComputedStyle(popupLayer); if (style.display !== 'none') { const text = popupLayer.textContent.toLowerCase(); if (text.includes('您已完成这个活动') || text.includes('已完成这个活动')) { log.info('检测到完成弹窗,不刷新网页'); return; } } } // 没有弹窗,刷新网页 refreshPage(); }, CONFIG.REFRESH_SECONDS * 1000); } // ============ 自动播放视频 ============ function autoPlayVideo() { const video = document.querySelector('video'); if (!video) return false; video.muted = true; video.volume = 0; video.play().then(() => { log.success('视频已开始播放'); updateStatus('🟢 挂机学习中...|邓老AI编程制作', 'red'); startReplayLoop(); // 启动重复播放 startRefreshTimer(); // 启动刷新计时 }).catch(() => { clickPlayButton(); }); return true; } // ============ 点击播放按钮 ============ function clickPlayButton() { const selectors = [ '.play-button', '.video-play-btn', '.player-play', 'button[class*="play"]', '.vjs-big-play-button', '.play-icon', 'button[title*="播放"]' ]; for (const selector of selectors) { const btn = document.querySelector(selector); if (btn && btn.offsetParent !== null) { triggerClick(btn); log.success('已点击播放按钮'); startReplayLoop(); startRefreshTimer(); return true; } } return false; } // ============ 关闭弹窗 ============ function closePopup() { const popupLayer = document.querySelector('.mylayer-layer.mylayer-openBtns'); if (!popupLayer) return false; const style = window.getComputedStyle(popupLayer); if (style.display === 'none') return false; log.success('检测到完成弹窗'); updateStatus('🟡 正在关闭弹窗...|邓老AI编程制作', 'orange'); const confirmBtn = popupLayer.querySelector('button.mylayer-btn.type1'); if (confirmBtn) { triggerClick(confirmBtn); log.success('已点击确定按钮'); return true; } const closeBtn = popupLayer.querySelector('a.mylayer-closeico'); if (closeBtn) { triggerClick(closeBtn); log.success('已点击关闭按钮'); return true; } return false; } // ============ 点击下一个活动 ============ function clickNextActivity() { if (hasClickedNext) return false; const nextBtn = document.querySelector('a.btn.next.crt'); if (nextBtn && nextBtn.offsetParent !== null) { triggerClick(nextBtn); log.success('已点击下一个活动'); hasClickedNext = true; stopReplayLoop(); setTimeout(() => { hasClickedNext = false; autoPlayVideo(); }, 3000); return true; } // 备选查找 const allBtns = document.querySelectorAll('a, button'); for (const btn of allBtns) { if (btn.textContent.includes('下一个活动') && btn.offsetParent !== null) { triggerClick(btn); log.success('已点击下一个活动(备选)'); hasClickedNext = true; stopReplayLoop(); setTimeout(() => { hasClickedNext = false; autoPlayVideo(); }, 3000); return true; } } return false; } // ============ 监听弹窗 ============ function startMonitoring() { const observer = new MutationObserver(() => { const popupLayer = document.querySelector('.mylayer-layer.mylayer-openBtns'); if (popupLayer) { const style = window.getComputedStyle(popupLayer); if (style.display !== 'none') { const text = popupLayer.textContent.toLowerCase(); if (text.includes('您已完成这个活动')) { log.success('检测到完成弹窗!'); stopReplayLoop(); closePopup(); setTimeout(clickNextActivity, 1000); } } } }); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); } // ============ 启动 ============ function start() { createStatusDisplay(); startMonitoring(); setTimeout(() => { if (!autoPlayVideo()) { // 如果没找到视频,等待3秒再试 setTimeout(autoPlayVideo, 3000); } }, 2000); } if (document.readyState === 'complete') { start(); } else { window.addEventListener('load', start); } })();