Greasy Fork

Greasy Fork is available in English.

GYB+SYB

针对江西省补贴性线上职业技能培训官网

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         GYB+SYB
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @author       tao
// @include      https://jiangxi.zhipeizaixian.com/study/*
// @description  针对江西省补贴性线上职业技能培训官网
// @grant        none
// ==/UserScript==
function queryRootClassName() {
  let regex = /content_wrap.*/;
  for (let i of document.querySelectorAll("div")) {
    if (regex.test(i.className)) {
      return i.className;
    }
  }
}
const regexUnitId = /unit_id=(\d.*)(&+)/;

const waitVideoList = setInterval(() => {
  const rootClassName = queryRootClassName();
  if (rootClassName == undefined) {
    console.log("等待网页加载");
    return;
  }
  const linkTagList = document.querySelectorAll("." + rootClassName + " a");
  const lastUnitId =
    linkTagList[linkTagList.length - 1].href.match(regexUnitId)[1];
  const check = setInterval(() => {
    let currentVideo = document.querySelector("video");
    const currentUnitId = location.search.match(regexUnitId)[1];
    let currnetIndex = 0;
    linkTagList.forEach((tag, index) => {
      if (
        (tag != undefined && tag.href != undefined) ||
        tag.href.indexOf("unit_id") != -1
      ) {
        let unitId = tag.href.match(regexUnitId)[1];
        if (unitId == currentUnitId) currnetIndex = index;
      }
    });
    if (currentVideo.readyState === 4) {
      currentVideo.play();
      const timeout = currentVideo.duration - currentVideo.currentTime;
      console.log(
        "共有" +
          linkTagList.length +
          "个视频,当前位于第" +
          currnetIndex +
          "个, 下一个视频在 " +
          timeout +
          " 秒后播放"
      );
      if (timeout == 0) {
        if (currentUnitId == lastUnitId) {
          console.log("视频观看结束");
          clearInterval(check);
        } else {
          location.href = linkTagList[currnetIndex + 1].href;
        }
      }
    } else {
      console.log("等待视频载入");
    }
  }, 1000);
  clearInterval(waitVideoList);
}, 1000);