// ==UserScript== // @name 浏览器你长这么大了要学会自己播放 - EASY在线 // @namespace Violentmonkey Scripts // @match https://neancts.gdei.edu.cn/* // @grant none // @license MIT // @icon https://neancts.gdei.edu.cn/common/vue/img/userCenter/boy_head.png // @version 0.98 // @author OpenAI GPT & BLUE声色 // @description 2025年6月11日更新,大食省专用! // @downloadURL none // ==/UserScript== function ensureVideoPlaying() { const video = document.querySelector('video'); if (video) { video.muted = true; // 静音 video.volume = 0; // 双保险:静音音量 if (video.paused) { video.play(); } } } ensureVideoPlaying(); // 👁️ 模拟页面始终处于激活状态 Object.defineProperty(document, 'hidden', { get: () => false, configurable: true }); Object.defineProperty(document, 'visibilityState', { get: () => 'visible', configurable: true }); document.addEventListener('visibilitychange', (e) => { e.stopImmediatePropagation(); }, true); setInterval(() => { window.dispatchEvent(new Event('focus')); }, 15000); function clickContinueCourse() { const btns = document.querySelectorAll('button.mylayer-btn3'); const contBtn = Array.from(btns).find(btn => btn.textContent.includes('继续学习')); if (contBtn) { contBtn.click(); } } function clickCompletedConfirm() { const doneBtn = Array.from(document.querySelectorAll('button.mylayer-btn.type1')) .find(btn => btn.textContent.includes('确定')); if (doneBtn) { doneBtn.click(); } } function simulateScrollActivity() { const scrollAmount = 1; // 1像素 const direction = Math.random() > 0.5 ? 1 : -1; window.scrollBy(0, scrollAmount * direction); } function simulateMouseMove() { const video = document.querySelector("video"); if (video) { const evt = new MouseEvent("mousemove", { view: window, bubbles: true, cancelable: true }); video.dispatchEvent(evt); } } function simulateClickOnBody() { const evt = new MouseEvent("click", { bubbles: true, cancelable: true, view: window, clientX: 10, clientY: 10 }); document.body.dispatchEvent(evt); } let checkNextInterval = setInterval(checkAndClickNext, 10000); // 每10秒检查一次 async function checkAndClickNext() { try { let isCompleted = false; // 尝试从所有
标签中找到包含“要求观看视频”的那一行 const pTags = Array.from(document.querySelectorAll('p')); const progressLine = pTags.find(p => p.textContent.includes('要求观看视频')); if (progressLine) { const text = progressLine.textContent; if (text.includes('您已完成观看')) { isCompleted = true; } else { const match = text.match(/要求观看视频(\d+)分钟.*?您已观看(\d+)分钟/); if (match) { const required = parseInt(match[1], 10); const watched = parseInt(match[2], 10); if (watched >= required) { isCompleted = true; } } } } if (isCompleted) { const nextBtn = Array.from(document.querySelectorAll('a.btn-next')) .find(a => a.innerText.includes('下一活动')); if (nextBtn) { const isDisabled = nextBtn.classList.contains('disabled') || nextBtn.style.pointerEvents === 'none' || nextBtn.disabled === true; if (!isDisabled) { nextBtn.click(); clearInterval(checkNextInterval); } else { console.warn('⚠️ 找到“下一活动”但按钮不可点击,可能是最后一项。'); await notifyUser('提示:已完成当前活动,但“下一活动”无法点击。请检查是否已经是最后一个。'); clearInterval(checkNextInterval); } } else { console.warn('⚠️ 没有找到“下一活动”按钮。'); await notifyUser('提示:已完成当前活动,但没有找到“下一活动”按钮。可能是最后一项。'); clearInterval(checkNextInterval); } } } catch (err) { console.error('❌ 检查“下一活动”时出错:', err); clearInterval(checkNextInterval); } } // 🔔 通知函数(async) async function notifyUser(message) { if (Notification.permission === 'granted') { new Notification('📘 EASY在线提醒', { body: message, }); } else if (Notification.permission !== 'denied') { const permission = await Notification.requestPermission(); if (permission === 'granted') { new Notification('📘 EASY在线提醒', { body: message, }); } else { alert(message); // 拒绝通知权限用 alert 替代 } } else { alert(message); // 通知被拒绝则用 alert } } // 每 5 秒执行一次的操作 setInterval(() => { ensureVideoPlaying(); }, 5 * 1000); // 每 7 秒执行一次的操作 setInterval(() => { clickContinueCourse(); clickCompletedConfirm(); }, 7 * 1000); // 每 13 秒执行一次的操作 setInterval(() => { simulateScrollActivity(); simulateClickOnBody(); }, 13 * 1000); // 每 17 秒执行一次的操作 setInterval(() => { simulateMouseMove(); }, 17 * 1000);