Greasy Fork

Greasy Fork is available in English.

电子科技大学专升本课程助手

自动化挂机完成课程任务

当前为 2021-06-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         电子科技大学专升本课程助手
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动化挂机完成课程任务
// @author       ZaneBill
// @match        https://xuexi.qsxueli.com/web/
// @grant        none
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @require      http://libs.baidu.com/jquery/1.8.3/jquery.min.js
// @require      http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js
// ==/UserScript==

(function() {
  'use strict';
  $(document).ready(function(){
    let operateBox = "<div class='operateBox'><div class='videoBox'><span>视频课程:</span><span class='startVideo'>点击开始</span></div><div class='pdfBox'><span>课程资料:</span><span class='startPDF'>点击开始</span></div></div>"
    $('body').append(operateBox)
    $('.operateBox').css({
      'position': 'fixed',
      'top': '230px',
      'right': '30px',
      'background': '#fff',
      'border-radius': '4px',
      'padding': '5px'
    })
    $('.videoBox').css({
      'height': '30px',
      'line-height': '30px'
    })
    $('.startVideo').css({
      'color': 'red',
      'cursor': 'pointer'
    })
    $('.pdfBox').css({
      'height': '30px',
      'line-height': '30px'
    })
    $('.startPDF').css({
      'color': 'red',
      'cursor': 'pointer'
    })
    let needPlayPdfList = []
    let videoInterval,pdfInterval
    let isInitVideo = true
    let isInitPDF = true
    $('.startVideo').on('click', function(){
      if($('.startVideo').text() === '运行中') {
        clearInterval(videoInterval)
        $('.startVideo').text('点击开始')
        isInitVideo = true
        return
      }
      $('.startVideo').text('运行中')
      $('.ke_menu li')[1].click()
      window.onblur = null
      window.onmouseleave = null
      // 展开所有章节
      $('.shipinList').children().each((index ,ele) => {
        $(ele).addClass('show')
      })
      isInitVideo && autoPlayVideo()
      videoInterval = setInterval(() => {
        let isFinnish = $('.el-message-box__message').text() === '本小节学习已完成'
        let isClick = $('.el-message-box__wrapper').css('display') === 'none'
        isInitVideo = false
        if(isFinnish && !isClick){
          console.log('video已完成====', new Date())
          $('.el-message-box__btns .el-button--primary').click()
          autoPlayVideo()
        }
        let $video = $('#courseVideo video')[0]
        if($video && $video.paused){
          $video.play()
        }
      }, 3000);
    })
    
    $('.startPDF').on('click', function(){
      if($('.startPDF').text() === '运行中'){
        clearInterval(pdfInterval)
        $('.startPDF').text('点击开始')
        isInitPDF = true
        return
      }
      $('.startPDF').text('运行中')
      $('.ke_menu li')[2].click()
      window.onblur = null
      window.onmouseleave = null
      isInitPDF && autoPlayPDF()
      pdfInterval = setInterval(() => {
        isInitPDF = false
        if($(needPlayPdfList[0]).children().length){
          console.log('pdf已完成===', new Date())
          autoPlayPDF()
        }
      }, 3000);
    })
   
    function autoPlayVideo(){
      let needPlayList = []
      $('.shipinList .el-progress__text').each((index,ele)=>{
        if($(ele).text()){
            needPlayList.push(ele)
          }
        })
      $(needPlayList[0]).click()
    }

    function autoPlayPDF(){
      needPlayPdfList = []
      $('.ziliaoList .el-progress__text').each((index,ele)=>{
        if($(ele).text()){
          needPlayPdfList.push(ele)
        }
      })
      $(needPlayPdfList[0]).click()
    }
  })
})();