zzzz_wsxy_getData

不再需要:网上学院函数库:获取数据

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greatest.deepsurf.us/scripts/395748/771251/zzzz_wsxy_getData.js

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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_getData
// @namespace     Vionlentmonkey
// @version       0.6
// @description   网上学院函数库:获取数据
// ==/UserScript==

// 课程学分学时等信息
const getCourseInfo = async coursePk => {
  const viewURL = `${location.origin}/sfxzwsxy//jypxks/modules/train/course/course_view.jsp?coursePk=${coursePk}`;
  const response = await fetch(viewURL, {
    method: 'POST',
    body: 'blob'
  });
  const blob = await response.blob();
  const csInfoHtml = await binary2Text(blob);
  const elements = htmlToElements(csInfoHtml);
  const courseCredit = Number(elements.querySelectorAll('#subjectInfo td')[7].textContent.trim());
  const courseTime = Number(elements.querySelectorAll('#extendInfo td')[3].textContent.trim());
  const courseInfo = {
    courseCredit,
    courseTime
  };
  return courseInfo;
};

// 获取课程对应的 iframe 资源地址,为获取播放器类型做准备。
const getFrameURL = async applyPk => {
  const trainURL =
    location.origin +
    '/sfxzwsxy/jypxks/modules/train/ware/course_ware_view.jsp?applyPk=' +
    applyPk +
    '&courseType=1';
  const response = await fetch(trainURL, {
    method: 'POST',
    body: 'blob'
  });
  const blob = await response.blob();
  const csInfoHtml = await binary2Text(blob);
  const elements = htmlToElements(csInfoHtml);
  const warePath = elements.getElementById('warePath').value;
  const iframeURL = 'http://218.94.1.181:5088/unzipapp/project/ware' + warePath;
  //console.log('iframeURL: ' + iframeURL);
  return iframeURL;
};

// 部分少见的新型播放器会弹出 confirm,避开为宜。
const checkVideoPlayerType = async (applyPk, callback) => {
  // 未报名课程 applyPk === ''
  if (!applyPk) {
    console.log('未传入有效参数 applyPk');
  }
  const iframeVideoPlayerType = {
    method: 'POST',
    // Fetch 不能获取跨域数据
    url: await getFrameURL(applyPk),
    onload: response => {
      const csInfoHtml = response.responseText;
      const elements = htmlToElements(csInfoHtml);
      const isNewPlayer = elements.getElementById('video');
      // return 永远为 undefined,以回调处理
      callback(isNewPlayer, applyPk);
    }
  };
  GM_xmlhttpRequest(iframeVideoPlayerType);
};