// ==UserScript== // @name 东营继续教育 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 模拟人工采用音频模式学习 // @author xuefeng // @match *://*.yxlearning.com/* // @grant none // @license // @downloadURL none // ==/UserScript== (function () { 'use strict'; // 声明一个存储当前课程的每章节id的数组 var vID = []; // 获取所有 class 为 "pt5" 的 ul 元素 var ulElements = document.querySelectorAll('ul.pt5'); // 遍历每个 ul 元素 ulElements.forEach(function (ul) { // 获取 ul 元素下的所有 li 元素 var liElements = ul.querySelectorAll('li'); // 遍历每个 li 元素并获取其 id liElements.forEach(function (li) { vID.push(li.id); }); }); console.log(vID); // 输出每个 li 元素的 id // 视频播放 function waitForElementThenPlay() { var vlist = document.querySelectorAll("video"); for (var i = 0; i < vlist.length; i++) { // 当前视频为暂停状态则自动播放 if (vlist[i].paused) { vlist[i].play(); } } } // 处理每个章节 function handleChapter(index) { if (index >= vID.length) { console.log('所有章节已播放完毕'); return; } var chapterId = vID[index]; document.querySelectorAll('li[id="' + chapterId + '"]')[0].click(); // 添加延迟,确保视频加载完成 setTimeout(function () { waitForElementThenPlay(); // 监听视频播放完成事件 var video = document.querySelectorAll("video")[1]; video.addEventListener('ended', function () { console.log('视频播放完成,处理下一个章节'); handleChapter(index + 1); }); }, 1000); // 延迟 1 秒 } // 开始处理第一个章节 handleChapter(0); // document.querySelector('input[value="跳过"]').click() // $.removeCookie('love', { domain: "qlteacher.com" }); })();