Greasy Fork

Greasy Fork is available in English.

【√】尔雅通识课视频学习完成自动翻页

主要用于检测尔雅通识课的视频完成播放自动进入下一章

当前为 2021-09-17 提交的版本,查看 最新版本

// ==UserScript==
// @name         【√】尔雅通识课视频学习完成自动翻页
// @namespace    ScriptTurnPages:[email protected]
// @version      1.1
// @description  主要用于检测尔雅通识课的视频完成播放自动进入下一章
// @author       ShenHaiSu
// @match        https://mooc1.chaoxing.com/mycourse/studentstudy*
// @match        https://mooc1-1.chaoxing.com/mycourse/studentstudy*
// @match        https://mooc1-3.chaoxing.com/mycourse/studentstudy*
// @icon         https://www.google.com/s2/favicons?domain=mju.edu.cn
// @require      https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function() {
  let waitTime = 2000   //页面加载后2000毫秒开始运行脚本
  let onceTime = 5000   //单次循环检测5000毫秒进行一次
  let waitWorkTime = 180 //180秒)三分钟等待时间。等待答题的总计时间,如果超过这个时间,将会直接跳下一页。不等待继续答题。 

  let nowWorkTime = 0
  setTimeout(() => {
    console.log("翻页脚本开始运行")
    setInterval(() => {
      let $active = $(".prev_ul .active").eq(0)
      let $lastCompleted = $(".posCatalog_active").eq(0)
      function ifLasttab(){
        if (($active.index()) == ($active.parent().children().length-1)){
          nextChapter()
        }else{
          $active.parent().children().eq($active.index() + 1).click()
        }
      }
      function nextChapter(){
        let $nowCompleted = $lastCompleted.parent()
        if ( ($nowCompleted.index()) == ($nowCompleted.parent().children().length -1) ){
          console.log("当前是本章节最后一节课")
          let $nextUl = $nowCompleted.parent().parent().parent().parent().children().eq($nowCompleted.parent().parent().parent().index()+1)
          let $nextClass = $nextUl.children().eq(1).children().eq(0).children().children().eq(0).children().eq(0)
          console.log($nextClass)
          $nextClass.click()
        }else{
          console.log("当前不是本章节最后一节课")
          let $nextLi = $nowCompleted.parent().children().eq($(".posCatalog_active").eq(0).parent().index()+1)
          $nextLi.children().children().click()
        }
      }
      if ( $active[0].innerText.match(/学习目标/g)){
        console.log("当前位于学习目标,无内容,立即跳过")
        ifLasttab()
      }else if ($active[0].innerText.match(/视频/g)){
        if ( ($("#iframe").contents().find(".ans-job-finished")).length == 0){
          console.log("任务点未完成")
        }else{
          console.log("任务点已完成")
          ifLasttab()
        }
      }else if ($active[0].innerText.match(/章节测验/g)){
        if ( ($("#iframe").contents().find(".ans-job-finished")).length == 0){
          console.log("任务点未完成" + nowWorkTime)
          if (nowWorkTime <= waitWorkTime){
            nowWorkTime = nowWorkTime + 5
          }else{
            ifLasttab()
            nowWorkTime = 0
          }
        }else{
          console.log("任务点已完成")
          ifLasttab()
        }
      }else{
        if ( ($("#iframe").contents().find(".ans-job-finished")).length == 0){
          console.log("任务点未完成")
        }else{
          console.log("任务点已完成")
          ifLasttab()
        }
      }
    }, onceTime);
  }, waitTime);
})();