JumpVideo

skip video

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         JumpVideo
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  skip video
// @author       You
// @match        https://lms.ouchn.cn/course/*/learning-activity/*
// @icon         https://www.google.com/s2/favicons?domain=ouchn.cn
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
     check();
    // Your code here...
})();

function check(){
    var retryCount = 0;
    var maxRetry = 3;
    var currentURL = window.location.href;
    var isNext = false;
    console.log("经过测试,interval 在切换视频时不会改变");
    var lock = setInterval(function(){
        console.log("开始检测是否播放完毕.....");
        let video = document.querySelector('#video video');
        if (currentURL !== window.location.href && isNext == true) {
          currentURL = window.location.href;
          isNext = false;
        }else if(currentURL == window.location.href && isNext == true){
            console.log("出现故障了,无法跳转到下一个作业,清除定时作业,lock:",lock);
            clearInterval(lock);
        }
        if(video == null || typeof video == 'undefined'){
            if(retryCount < maxRetry){
                console.log('可能是由于加载缓慢导致的未初始化问题,重试次数:'+retryCount+',最大次数:'+maxRetry)
                retryCount++;
                return;
            }else{
                console.log("判定为当前页面没有视频,直接下一个作业");
                retryCount = 0;
                $(".next").click();
                isNext = true;
                return;
            }

        }
        if (video.paused && video.duration != video.currentTime) {
            video.playbackRate=4;
            video.muted = true;
            $('.mvp-toggle-play').click();
            return;
        }else if(video.duration == video.currentTime){
            console.log("播放完毕,下一个视频");
            $(".next").click();
            isNext = true;
        }},3000);
}