// ==UserScript== // @name 北医三继续播自动确定 // @namespace http://tampermonkey.net/ // @version 0.2.2 // @description 当页面出现可见的"继续播放提醒"弹窗时,自动点击确定按钮 // @author Mzky // @match *://edu.puh3.net.cn/* // @grant none // ==/UserScript== (function() { 'use strict'; // 功能1:处理"继续播放提醒"弹窗,点击确定按钮 function handleReminderModal() { // 查找包含"继续播放提醒"文字的标题元素 const titleElements = document.querySelectorAll('.x-modal-title'); let targetModal = null; titleElements.forEach(title => { if (title.textContent.trim() === '继续播放提醒') { targetModal = title.closest('.x-modal'); } }); // 仅当弹窗可见时点击确定 if (targetModal && window.getComputedStyle(targetModal).display === 'block') { const confirmButton = targetModal.querySelector('.x-modal-button.OK'); if (confirmButton) { console.log('检测到可见的"继续播放提醒"弹窗,自动点击确定'); confirmButton.click(); return true; } } return false; } // 功能2:独立点击播放按钮(不依赖弹窗) function clickPlayButton() { // 查找播放按钮元素 const playContainer = document.querySelector('xg-start.xgplayer-start'); if (!playContainer) return false; // 检查播放图标状态(显示播放图标时才点击) const playIcon = playContainer.querySelector('.xgplayer-icon-play'); const pauseIcon = playContainer.querySelector('.xgplayer-icon-pause'); // 播放图标可见,且暂停图标不可见时,说明需要点击播放 if (playIcon && pauseIcon && window.getComputedStyle(playIcon).display !== 'none' && window.getComputedStyle(pauseIcon).display === 'none') { console.log('检测到需要播放,自动点击播放按钮'); playContainer.click(); return true; } return false; } // 统一检查入口,分别执行两个独立功能 function checkAllFunctions() { handleReminderModal(); // 处理弹窗(独立功能1) clickPlayButton(); // 点击播放按钮(独立功能2) } // 初始检查 checkAllFunctions(); // 创建监听器,分别监测两个功能的可能变化 const observer = new MutationObserver((mutations) => { mutations.forEach(mutation => { if (mutation.addedNodes.length > 0 || mutation.type === 'attributes') { checkAllFunctions(); } }); }); // 监听配置 observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style'] }); // 定时检查,确保两个功能都能被触发 setInterval(checkAllFunctions, 6000); })();