传智播客预习

可以完成传智播客预习的视频,题目暂时不可以

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         传智播客预习
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  可以完成传智播客预习的视频,题目暂时不可以
// @author       [email protected]
// @match        https://stu.ityxb.com/preview/detail/*
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @icon         https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant        none
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';
window.addEventListener('load', function() {
    let video = $(".point-item-box")
let sum = video.length //总共节点
let cur = $(".playing-status").parent().index() //进入先获取当前位置

let cName = document.querySelector('#videoPlayer div div').className.split('controlbgbar')[1]

$(`.playbackratep${cName} p`)[0].click() //二倍速
$(`.mute${cName}`).click() // 静音

//依次点击视频节点
let timer = null
timer = setInterval(a, 2000)


//判断章节是否完成
function a () {
  video[cur].click()
  cName = document.querySelector('#videoPlayer div div').className.split('controlbgbar')[1]

  if (video[cur].querySelector('.point-progress-box').innerHTML == '100%') {

  } else if ($(`.play${cName}`)[0].style.display == 'block') { //点击播放  为true暂停
    setTimeout(() => {
      $(`.mute${cName}`).click() // 静音
      $(`.play${cName}`).click() // 播放
    }, 1000)
    clearInterval(timer)
    ifResult()
  }
  cur++
  if (cur == sum) {
    clearInterval(timer)
  }
}


//判断视频是否看完
let pass = null
function ifResult () {
  pass = setInterval(() => {
    let timeList = document.querySelector(`.timetext${cName}`).innerHTML.split('/')
    console.log('正在观看');
    if (timeList[0].trim() == timeList[1].trim() && timeList[0].trim() != '00:00' && timeList[0].trim() != '00:00') {
      console.log('下个视频');
      clearInterval(pass)
      timer = setInterval(a, 2000)
    }
  }, 1000)
}

// 点击切换章节
$('.point-item-box .point-name-box').click(function (e) {
  cur = $(e.target).parents('.point-item-box').index() //重置当前位置
  console.log(cur);
  // 重置定时器
  clearInterval(pass)
  clearInterval(timer)
  timer = setInterval(a, 2000)
})
}, false);
})();