wsxy_autoSignup

网上学院函数库:自动报名

Mint 2020.02.04.. Lásd a legutóbbi verzió

Ezt a szkriptet nem ajánlott közvetlenül telepíteni. Ez egy könyvtár más szkriptek számára, amik tartalmazzák a // @require https://updategf.qytechs.cn/scripts/396002/769959/wsxy_autoSignup.js hivatkozást.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name          wsxy_autoSignup
// @namespace     Vionlentmonkey
// @version       0.2
// @description   网上学院函数库:自动报名
// @require       https://greasyfork.org/scripts/395748-wsxy-getdata/code/wsxy_getData.js
// @grant         none
// ==/UserScript==

// 自动报名高学分课程。2020年初,高于1学分的有且仅有20门3学分课程。
const autoSignupMaxCredit = async () => {
  // 彩蛋:需要 iframe 提升才会执行
  if (window.top === window.self) {
    let courses = document.querySelectorAll('#requiredCourseTable .course');
    for await (let c of courses) {
      let coursePk = c.getElementsByClassName('coursePk')[0].textContent;
      let title = c.getElementsByClassName('title')[0].getAttribute('title');
      let jdjs = c.getElementsByClassName('jdjs')[0].textContent; // 进度
      let csInfo = await getCourseInfo(coursePk);
      let csCredit = csInfo.courseCredit;
      if (jdjs === '未报名') {
        // 自动报名高学分课程
        if (csCredit > 1) {
          console.log(`${csCredit}学分:${title}`);
          c.click();
          console.log('Click:' + title);
          const info = document.getElementsByClassName('layui-layer-btn0');
          if (info.length === 1) {
            document.getElementsByClassName('layui-layer-btn0')[0].click();
            console.log('报名:' + title);
          }
        }
      }
    }
  }
};

// 自动报名高学时课程
const autoSignupMaxTime = async () => {
  // 数组存储所有未报名课程故的课时数据
  let timesArray = [];
  // 获取所有未报名课程的子节点。若直接使用所有必修课程,可能出现课程数字相同而对已报名课程二次点击。
  let unCoursesJdpoint = document.querySelectorAll(
    '#requiredCourseTable .course > .jdpoint[style]'
  );
  for await (let u of unCoursesJdpoint) {
    // 由子节点获取父节点从而获取课程编号
    let coursePk = u.parentNode.getElementsByClassName('coursePk')[0].textContent;
    let applyPk = await csPk2applyPk(coursePk);
    let csInfo = await getCourseInfo(coursePk);
    let csTime = csInfo.courseTime;
    skipNewVideoPlayerType(applyPk, (isNewPlayer, applyPk) => {
      if (isNewPlayer) {
        console.log(`跳过 applyPk: ${applyPk}`);
        timesArray.push(-Infinity);
      } else {
        timesArray.push(csTime);
      }
    });
  }
  let longest = Math.max(...timesArray);
  console.log(longest);
  let indexMax = timesArray.indexOf(longest);
  // 出现过该错误 indexMax === -Infinity 导致:
  // TypeError: unCoursesJdpoint[timesArray.indexOf(...)] is undefined
  if (unCoursesJdpoint[indexMax]) {
    unCoursesJdpoint[indexMax].parentNode.click();
  } else {
    location.reload(true);
  }
  const notice = document.getElementsByClassName('layui-layer-btn0');
  if (notice.length === 1) {
    document.getElementsByClassName('layui-layer-btn0')[0].click();
  }
};