// ==UserScript== // @name 国家中小学智慧教育平台 2022年“暑期教师研修”专题 刷课脚本 // @namespace http://tampermonkey.net/ // @version 0.1 // @license CC BY-NC-SA // @description Just a normal script // @author Zed Wong // @match https://www.zxx.edu.cn/teacherTraining/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; setTimeout(main, 5000); function main(){ console.log('刷课脚本开始运行'); var vid = document.getElementsByTagName("video")[0]; vid.muted = true; vid.play(); console.log('开始播放'); var total_ep = document.getElementsByClassName('resource-item').length; console.log('总共集数:',total_ep); var current_index; document.getElementsByClassName('resource-item').forEach(function(element,index){ if (element.classList.length === 3) { current_index = index; }}); console.log('当前集号:',current_index); vid.addEventListener('ended', function() { if (current_index <= total_ep) { console.log('播放结束,切换下一个视频'); document.getElementsByClassName('resource-item')[current_index].click(); current_index += 1; setTimeout(next(current_index), 2000); } else { console.log("该章节已挂机完成。"); } }, false); } function next(current_index) { document.getElementsByClassName('resource-item')[current_index+=1].click(); console.log('已切换到视频',current_index); } })();