// ==UserScript== // @name 华医小助手 // @namespace https://docs.scriptcat.org/ // @version 1.0.0 // @description 视频助手 自动播放视频 // @author You // @match https://*/* // @grant none // @noframes // ==/UserScript== setInterval(courseAutoClickPlay, 15000);// 15秒检查并点击一次 function courseAutoClickPlay() { // 自动点击休息按钮 //console.log("已播放最大时长=" + getMaxPlayTime() + ";当前时间=" + player.j2s_getCurrentTime() + ";总时长=" + player.j2s_getDuration()); let el = document.querySelector(".study_diaog"); if(el){ //console.log(getComputedStyle(el).display); if (getComputedStyle(el).display !== 'none') { el.style.display = 'none'; player.j2s_resumeVideo(); } } // 当前播放时间小于总时间则继续播放 if(Math.trunc(player.j2s_getCurrentTime()) < player.j2s_getDuration()) { return; } // 获取所有的进度条元素和对应的课程学习按钮 var progresses = document.querySelectorAll('.cw-progress-text'); var courseLearnButtons = document.querySelectorAll('.lis-inside-content'); // 遍历进度条元素 for (var i = 0; i < progresses.length; i++) { // 获取进度条的百分比数值 var progressNum = progresses[i]; var progressValue = progressNum ? progressNum.textContent.trim() : '0%'; //console.log('进度条 ' + (i + 1) + ' 的数值: ' + progressValue); // 根据进度值点击对应的课程学习按钮 if (progressValue !== '100%' && i < courseLearnButtons.length) { // 如果进度不等于100%,则点击对应的课程学习按钮 clickCourseLearnButton(courseLearnButtons[i]); return; // 只点击第一个不等于100%的进度对应的按钮 } else if (progressValue === '100%' && i < progresses.length - 1) { // 如果当前进度等于100%,则点击下一个进度对应的按钮 if (progresses[i + 1].textContent.trim() !== '100%') { clickCourseLearnButton(courseLearnButtons[i + 1]); return; } } } } // 点击进度对应的课程学习按钮 function clickCourseLearnButton(button) { if (button) { //console.log('点击课程学习按钮:', button); button.click(); } }