wsxy_autoSignup

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

04.02.2020 itibariyledir. En son verisyonu görün.

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://updategf.qytechs.cn/scripts/396002/769959/wsxy_autoSignup.js

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
  }
};