// ==UserScript== // @name (完全免费)枣庄专业课播放助手(精简版) // @namespace http://tampermonkey.net/ // @version 2.02 // @description 视频进度100%自动切换,自动关闭问题弹窗(无界面后台运行) // @author qqqqqc. // @match *://*.yxlearning.com/* // @grant GM_getValue // @grant GM_setValue // @run-at document-idle // ==/UserScript== (function() { 'use strict'; const config = { autoPlayNext: GM_getValue('autoPlayNext', true), checkInterval: 2000, questionCheckInterval: 5000 }; function getVideoList() { return Array.from(document.querySelectorAll('li.videoLi')).map(item => { const title = item.getAttribute('data-original-title') || item.querySelector('.video-info').textContent.trim(); const progressText = item.querySelector('.badge').textContent; const progress = parseInt(progressText) || 0; const isActive = item.classList.contains('active'); return { element: item, id: item.id, title: title, progress: progress, isActive: isActive }; }); } function autoPlayNextVideo() { const videoList = getVideoList(); const currentVideo = videoList.find(video => video.isActive); if (currentVideo && currentVideo.progress >= 100) { const currentIndex = videoList.findIndex(video => video.isActive); if (currentIndex !== -1 && currentIndex < videoList.length - 1) { const nextVideo = videoList[currentIndex + 1]; nextVideo.element.click(); console.log(`[自动播放] 已切换到: ${nextVideo.title}`); } } } function checkAndHandleQuestion() { const questionElement = document.querySelector('div.bplayer-question-wrap[style="display: flex;"]'); if (questionElement) { questionElement.remove(); console.log('[问题弹窗] 已自动关闭'); setTimeout(() => { const playButton = document.querySelector('span.icon.bplayer-play-btn'); if (playButton) { playButton.click(); console.log('[问题弹窗] 已恢复播放'); } }, 2000); } } function init() { setInterval(() => { if (config.autoPlayNext) { autoPlayNextVideo(); } }, config.checkInterval); setInterval(() => { checkAndHandleQuestion(); }, config.questionCheckInterval); setInterval(() => { const currentVideo = document.querySelector('li.videoLi.active'); if (currentVideo) { const title = currentVideo.getAttribute('data-original-title') || currentVideo.querySelector('.video-info').textContent.trim(); const progress = currentVideo.querySelector('.badge').textContent; console.log(`[进度监控] 当前视频: ${title} | 进度: ${progress}`); } }, 5000); checkAndHandleQuestion(); console.log('[公需课助手] 脚本已启动 - 精简版 v2.00'); console.log('[提示] 当前模式: 后台自动运行(无界面)'); } init(); })();