刷课时专用
// ==UserScript==
// @name 在线学习autoPlayer
// @namespace http://tampermonkey.net/
// @version 0.11
// @description 刷课时专用
// @author Jero
// @match https://www.tampermonkey.net/changelog.php?version=4.14&ext=dhdg
// @match https://hzzj-kfkc.webtrn.cn/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// @run-at document-end
// @license AGPL
// ==/UserScript==
(function() {
'use strict';
var __main = function () {
var iframe1 = document.querySelector('.contentIframe')
var iframe2 = iframe1.contentWindow.document.querySelector('#mainFrame')
var sectionwraps = iframe1.contentWindow.document.querySelectorAll('.s_sectionwrap')
var container_display_button = iframe2.contentWindow.document.querySelector('#container_display_button')
var pointtis = iframe1.contentWindow.document.querySelectorAll('.s_pointti')
var index = 0
var videoEvent = function () {
// 播放完成移除事件
var video = iframe2.contentWindow.document.querySelector('video')
video.removeEventListener('ended', videoEvent)
setTimeout(function () {
// 播放下一个
index++
pointtis[index].click()
}, 2000)
// 再次绑定事件
setTimeout(monitorVideo, 10000)
}
var monitorVideo = function () {
var video = iframe2.contentWindow.document.querySelector('video')
video.addEventListener('ended', videoEvent)
}
for (var i = 0; i < sectionwraps.length; i++) {
var sectionwrap = sectionwraps[i];
if (sectionwrap.style.display !== 'none') {
index = i
}
}
// 进入课程自动播放
container_display_button.click()
setTimeout(function () {
// 监听 video 播放结束事件
monitorVideo()
}, 2000)
}
__main()
// Your code here...
})();