教师研修网刷课-脚本

这是一个用于教师研修网刷课的脚本

// ==UserScript==
// @name         教师研修网刷课-脚本
// @namespace    www.tuziang.com/combat/128709.html
// @version      1.1
// @description  这是一个用于教师研修网刷课的脚本
// @author       Tuziang
// @icon         http://i.yanxiu.com/favicon.ico
// @match        *://i.yanxiu.com/uft/course/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var clockTip = $('.clock-tip')[0];
    var playButton = $('.play-btn-container .btn-body')[0];
    setInterval(function() {
        //检查是否弹出10分钟的提示,有则点击
        if (clockTip && clockTip.style.display === 'block')
            clockTip.click();
        //检查是否播放完毕,完毕则切换下一个视频
        if (playButton && playButton.innerText === '重播') {
            var videos = $('.video');
            var currentVideo = $('.video.click');
            var currentIndex = 0;
            videos.each(function(index, video) {
                if($(video).prop('href') === currentVideo.prop('href')) {
                    currentIndex = index;
                    return false;
                }
            });
            currentIndex++;
            currentIndex = currentIndex < videos.length ? currentIndex : 0;
            videos.eq(currentIndex)[0].click();
        }
    }, 5000);
})();