翱翔门户选课增强

翱翔门户选课增强,显示已选人数

目前為 2022-08-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         翱翔门户选课增强
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  翱翔门户选课增强,显示已选人数
// @author       2ndelement
// @match        https://jwxt.nwpu.edu.cn/course-selection/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nwpu.edu.cn
// @grant        none
// @run-at       document-end
// @namespace    https://github.com/2ndelement/nwpu-lesson-select-enhance
// @supportURL   https://github.com/2ndelement/nwpu-lesson-select-enhance
// @homepageURL  https://github.com/2ndelement/nwpu-lesson-select-enhance
// @license MIT
// ==/UserScript==
(function () {
  function run() {
    "use strict";
    var reg =
      /https:\/\/jwxt.nwpu.edu.cn\/course-selection\/#\/course-select\/(\d+)\/turn\/(\d+)\/select/;
    var groups = reg.exec(window.location.href);
var studentId = groups[1];
    var turnId = groups[2];

    var token = document.cookie.match(/token=([^;]+)/)[1];
    var getCourses = new XMLHttpRequest();
    getCourses.open(
      "GET",
      "https://jwxt.nwpu.edu.cn/course-selection-api/api/v1/student/course-select/selected-lessons/" +
        turnId +
        "/" +
        studentId,
      false
    );
    getCourses.setRequestHeader("Authorization", token);
    getCourses.send(null);
    var courses = JSON.parse(getCourses.responseText)["data"];
    var t = document.querySelectorAll("table.el-table__body")[0];
    var coursesDom = t.querySelectorAll("tr.el-table__row");
    for (var i = 0; i < coursesDom.length; i++) {
      var courseName = coursesDom[i].outerText.match(/(.*?)[\nU]/)[1].trim();
      var currentCourse = courses.find(
        (item) => item["course"]["nameZh"] == courseName
      );
      var pannel = coursesDom[i].querySelector(
        "div.control-label.pinned-label"
      );
      if (!pannel) {
      	continue;
      	}
      
      var getSelected = new XMLHttpRequest();
      getSelected.open(
        "GET",
        "https://jwxt.nwpu.edu.cn/student/for-std-lessons/info/" +
          currentCourse["id"],
        false
      );
      getSelected.send(null);
      groups = getSelected.responseText.match(
        /<th width="11%">已选学生数<\/th>\n.*?<td width="12%">(\d+)<\/td>\n.*?<th width="10%">待释放保留人数<\/th>\n.*?<td width="12%"><span>(\d+)<\/span><\/td>\n.*?\n.*?\n.*?<th>选课人数上限<\/th>\n.*?<td>(\d+)<\/td?/
      );
      pannel.innerText = groups[1] + "/" + groups[3];
    }
  }
  setTimeout(run, 500);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址