东奥会计人员在线继续教育刷课脚本

东奥会计人员在线继续教育

// ==UserScript==
// @name         东奥会计人员在线继续教育刷课脚本
// @namespace    https://www.tuziang.com/combat/128700.html
// @version      0.1
// @description  东奥会计人员在线继续教育
// @author       兔子昂
// @match        *://.dongao.com/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  var href = location.href
  var i
  var text
  var video
  if (href.indexOf("study/u/myCourse") != -1) {
    //我的课程页面
    for (i = 0; i < document.getElementsByClassName("operate-a active").length; i++) {
      //进入第一门未完成课程
      text = document.getElementsByClassName("operate-a active")[i].innerText
      if (text == "继续学习" || text == "开始学习") {
        document.getElementsByClassName("operate-a active")[i].click()
        break;
      }
    }
  }
  if (href.indexOf("lecture/lectureList") != -1) {
    //课程目录页面
    for (i = 0; document.getElementsByClassName("item-button1").length; i++) {
      text = document.getElementsByClassName("item-button1")[0].innerText
      if (text == "继续学习" || text == "开始学习") {
        document.getElementsByClassName("item-button1")[i].click()
        break;
      }
    }
  }

  if (href.indexOf("video/videoPlay") != -1) {
    //视频结束后回到目录
    video = document.getElementById("video");
    if (video.ended) {
      var endhref = href.indexOf("/videoShow")
      var prefix = href.substring(endhref)
      var cwId = href.substring(href.indexOf("cwID="), href.indexOf("&lectureID"))
      cwId = cwId.substring(5)
      location.href = endhref + "/cwweb/lecture/lectureList?cwID=" + cwId
    }
  }
})();