Greasy Fork is available in English.

🔥🔥贵州省专业技术人员继续教育自动刷课时脚本

全新的继续教育自动刷课时脚本,打开课件后就不用管了!!

// ==UserScript==
// @name        🔥🔥贵州省专业技术人员继续教育自动刷课时脚本
// @namespace   🔥🔥贵州省专业技术人员继续教育自动刷课时
// @match       http://www.gzjxjy.gzsrs.cn/personback/*
// @version     1.0
// @description 全新的继续教育自动刷课时脚本,打开课件后就不用管了!!
// @license     MIT
// ==/UserScript==

const page = (pathname) => {
  return new Promise(resolve => {
    const timer = setInterval(() => {
      if (pathname[0] === '/') {
        if (location.href.includes(pathname)) {
          clearInterval(timer)
          resolve()
        }
      } else {
        if (location.href.includes(pathname)) {
          clearInterval(timer)
          resolve()
        }
      }
    }, 300)
  })
}

const getElement = (selector) => {
  return new Promise(resolve => {
    const timer = setInterval(() => {
      const element = typeof selector === 'string' ? document.querySelector(selector) : selector

      if (element) {
        clearInterval(timer)
        resolve(element)
      }
    }, 60)
  })
}

page('/personback/#/learning').then(() => {
  getElement('video').then(video => {
    video.muted = true
  
    const playList = Array.from(document.querySelectorAll('.el-steps .el-step .title-step'))
    let currentIndex = 0
  
    const nextVideo = () => {
      let currentNow = Date.now()
  
      const timer = setInterval(async () => {
        if (isNaN(video.duration)) {
          video = await getElement('video')
          video.muted = true
        }
  
        if (Date.now() - currentNow < 15000) {
          if (video.paused) {
            video.play()
          }
  
          return
        }
  
        if (video.currentTime >= (video.duration - 1) && video.paused) {
          currentIndex += 1
  
          if (currentIndex >= playList.length) {
            currentIndex = 0
          }
    
          playList[currentIndex].click()
    
          clearInterval(timer)
  
          setTimeout(() => {
            nextVideo()
          }, 1000)
        }
      }, 1000)
    }

    setInterval(() => {
      const button = document.querySelector('.el-dialog__wrapper .el-button span')

      if (button) {
        button.click()
      }
    }, 1000)
  
    nextVideo()
  })
})