chinahrt刷课脚本

一个 chinahrt刷课 的小脚本

// ==UserScript==
// @name         chinahrt刷课脚本
// @namespace    https://www.tuziang.com/combat/128704.html
// @version      0.6
// @description  一个 chinahrt刷课 的小脚本
// @author       Tuziang
// @match        *://*.chinahrt.com/*
// @match        https://edu.scjxjypx.com/*
// @match        https://sichuan.chinamde.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
//去除视频失去焦点暂停限制
window.onfocus = function(){console.log('on focus')};
window.onblur = function(){console.log('on blur')};
//判断是课程预览界面
if(window.location.href.indexOf("course/preview?")!=-1){
    var sections = document.getElementsByClassName("fr menu-zt")
    var completed_number = 0
    for(var i = 0; i < sections.length; i ++){
        if(sections[i].innerText.indexOf("学习中") != -1){
            completed_number++
        }
    }
    document.getElementsByClassName("menu")[0].getElementsByTagName("a")[completed_number-1].click()
}

})();