在线学习autoPlayer

刷课时专用

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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...
})();