Greasy Fork

Greasy Fork is available in English.

三分屏课件自动播放

try to take over the world!

当前为 2020-03-30 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         三分屏课件自动播放
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  try to take over the world!
// @author       You
// @match        http://*/*
// @include      http://*/*
// @require      http://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function startPlay(chapter_n) {
    var $chapter = $(".chapter").eq(chapter_n);
    var id = $chapter.attr('data-id');
    var href = $chapter.attr('data-href');
    var assertType = $chapter.attr('data-assert-type');

    $('#course .chapter').removeClass('active');
    $chapter.addClass('active');

    window.global.player.pause();
    if ('link' === assertType) {
        $("#course").css("top", "2px");
        $('#chapter-iframe').attr('src', href);
    } else if ('video-sync' === assertType) {
        Chapter.load(id, href, function (chapter) {
            $("#course").css("top", "198px");
            var timerId = setInterval(function () {
                if (window.global.player) {
                    clearInterval(timerId);
                    if (chapter.mp4) {
                        window.global.study.startStudy(chapter);
                        window.global.player.loadByUrl(chapter.mp4, chapter.startTime / 1000);
                        window.global.player.play();
                    }
                }
            }, 100);
        });
    }
};
    window.addEventListener('load', (event) => {
        console.log('page is fully loaded');
        setInterval(function () {
            if (window.global.player) {
                var stat = window.global.player.getStatus();
                console.log(stat);
                if (stat == "ended") {
                    var active_chapter = 0;
                    var chapters = $(".chapter");
                    for (var i = 0; i < chapters.length; i++) {
                        if (chapters.eq(i).get(0).attributes["class"].value == "chapter active") {
                            active_chapter = i + 1;
                            break;
                        }
                    }
                    console.log(active_chapter);
                    startPlay(active_chapter);
                }}
        },5000)});

})();