// ==UserScript== // @name 【免费版】广东省药师协会公需课自动学习器(执业药师)▲收费版:https://scriptcat.org/zh-CN/script-show-page/6618 // @namespace http://tampermonkey.net/ // @version 1.0.1 // @description 免费自动学习公需课,1.0倍速播放+自动屏蔽题目 // @match https://www.gdysxh.com/my_classes/public_course/index.html // @match https://www.gdysxh.com/my_classes/public_course/video/* // @grant none // ==/UserScript== (function() { 'use strict'; // ================== 添加控制面板样式 ================== const style = document.createElement('style'); style.textContent = ` #video-control-panel-free { position: fixed; top: 10px; left: 10px; z-index: 99999; background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); border-radius: 12px; padding: 10px 16px; color: white; font-family: system-ui, -apple-system, sans-serif; box-shadow: 0 4px 15px rgba(0,0,0,0.2); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.2); min-width: 240px; font-size: 14px; text-align: center; animation: slideIn 0.3s ease; } #video-control-panel-free .title { font-size: 16px; font-weight: bold; margin-bottom: 5px; } #video-control-panel-free .info { font-size: 14px; opacity: 0.9; } #video-control-panel-free .paid-info { font-size: 13px; margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.3); color: #ffffaa; line-height: 1.4; } #video-control-panel-free .paid-info a { color: #fff; text-decoration: underline; font-weight: bold; } @keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } } .free-tip { position: fixed; top: 80px; left: 220px; background: rgba(0,0,0,0.85); color: #4facfe; padding: 6px 12px; border-radius: 8px; font-size: 12px; z-index: 99998; animation: fadeOut 2s ease forwards; pointer-events: none; } @keyframes fadeOut { 0% { opacity: 1; transform: translateY(0); } 70% { opacity: 1; transform: translateY(-5px); } 100% { opacity: 0; transform: translateY(-10px); display: none; } } `; document.head.appendChild(style); // 显示提示 function showTip(message) { const tip = document.createElement('div'); tip.className = 'free-tip'; tip.innerHTML = message; document.body.appendChild(tip); setTimeout(() => tip.remove(), 2000); } // 创建控制面板 function createControlPanel() { if (document.getElementById('video-control-panel-free')) return; const panel = document.createElement('div'); panel.id = 'video-control-panel-free'; panel.innerHTML = `
🎬 【免费版】公需课自动学习器
⚡ 1.0倍速自动播放 | 自动屏蔽题目 | 自动跳转下一课
`; document.body.appendChild(panel); // 为链接添加点击事件(请将 # 替换为您的实际链接) const link = document.getElementById('paid-version-link'); if (link) { link.addEventListener('click', (e) => { e.preventDefault(); // 请将下面的链接替换为您的实际收费版链接 window.open('https://example.com/buy', '_blank'); }); } } // 屏蔽题目弹窗 function blockExamPopups() { setInterval(() => { // 关闭layer弹窗 if (typeof layer !== 'undefined' && layer.closeAll) { layer.closeAll(); } // 移除常见弹窗元素 const popups = document.querySelectorAll('.layui-layer, .layui-layer-shade, .exam-modal, .question-dialog'); if (popups.length) { popups.forEach(el => el.remove()); console.log(`[免费版] 🛡️ 已清理 ${popups.length} 个弹窗`); } }, 1000); } // ================== 主逻辑 ================== const currentPath = window.location.pathname; console.log('[免费版] 当前页面:', currentPath); // 1. 课程列表页逻辑 if (currentPath === '/my_classes/public_course/index.html') { console.log('[免费版] 进入课程列表页,准备查找"待学习"课程...'); createControlPanel(); blockExamPopups(); // 列表页也清理弹窗 window.addEventListener('load', () => { setTimeout(() => { findAndJumpToCourse(); }, 1500); }); function findAndJumpToCourse() { // 查找"待学习"文字 const allElements = document.querySelectorAll('*'); let targetElement = null; for (let el of allElements) { if (el.children.length === 0 && el.innerText && el.innerText.trim() === '待学习') { targetElement = el; break; } } if (!targetElement) { console.warn('[免费版] ⚠️ 未找到"待学习"课程'); showTip('⚠️ 未找到待学习课程'); return; } // 向上查找包含播放链接的容器 let parentContainer = targetElement.closest('.course-item, li, tr, div, .list-group-item'); if (!parentContainer) { parentContainer = targetElement.parentElement; while (parentContainer && !parentContainer.querySelector('a[data-href*="video"], a[onclick*="open_video"]')) { parentContainer = parentContainer.parentElement; } } if (!parentContainer) { console.error('[免费版] ❌ 未找到播放链接容器'); return; } // 查找播放链接 const playLink = parentContainer.querySelector('a[data-href*="video"], a[onclick*="open_video"]'); if (!playLink) { console.error('[免费版] ❌ 未找到播放链接'); return; } let targetUrl = null; if (playLink.getAttribute('data-href')) { let href = playLink.getAttribute('data-href'); if (href.startsWith('/')) { targetUrl = 'https://www.gdysxh.com' + href; } else { targetUrl = 'https://www.gdysxh.com/my_classes/public_course/' + href; } } else if (playLink.getAttribute('onclick')) { const onclick = playLink.getAttribute('onclick'); const match = onclick.match(/open_video\([^,]*,\s*'([^']+)'/); if (match && match[1]) { targetUrl = `https://www.gdysxh.com/my_classes/public_course/video/course_id/${match[1]}/order_id/xxx.html`; } } if (targetUrl) { console.log(`[免费版] 🚀 跳转到: ${targetUrl}`); showTip('🚀 自动跳转到待学习课程'); window.location.href = targetUrl; } else { console.error('[免费版] ❌ 无法获取跳转链接'); } } } // 2. 视频播放页逻辑 else if (currentPath.startsWith('/my_classes/public_course/video/')) { console.log('[免费版] 进入视频播放页,准备自动播放...'); createControlPanel(); blockExamPopups(); // 播放页清理弹窗 let checkVideoInterval = setInterval(() => { const video = document.querySelector('video'); if (video) { clearInterval(checkVideoInterval); console.log('[免费版] ✅ 视频元素已加载'); initVideoControl(video); } else { console.log('[免费版] ⏳ 等待视频元素加载...'); } }, 500); function initVideoControl(video) { // 设置为1.0倍速 video.playbackRate = 1.0; console.log('[免费版] 🚀 播放速度: 1.0x'); showTip('▶️ 开始自动学习 (1.0x倍速)'); // 静音播放(避免自动播放策略限制) video.muted = true; // 自动播放 video.play().then(() => { console.log('[免费版] ✅ 视频已自动播放'); }).catch(e => { console.warn('[免费版] ⚠️ 自动播放失败,请手动点击播放', e); showTip('⚠️ 请手动点击视频播放'); }); // 检查视频是否结束 let endCheckInterval = setInterval(() => { if (video.ended) { console.log('[免费版] 🎉 视频结束,返回列表'); showTip('✅ 本节学习完成,即将跳转下一课'); clearInterval(endCheckInterval); window.location.href = 'https://www.gdysxh.com/my_classes/public_course/index.html'; } else { console.log(`[免费版] ⏰ 播放中: ${Math.floor(video.currentTime)}/${Math.floor(video.duration)}秒 | 速度: 1.0x`); } }, 5000); } } console.log('[免费版] 脚本已启动,公需课免费自动学习'); console.log('[免费版] 💰 收费版10元/永久:公需课最高8.0倍速+专业课最高2.5倍速+自动屏蔽题目'); })();