Greasy Fork

Greasy Fork is available in English.

在线学习autoPlayer

刷课时专用

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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...
})();