JUST Kit

用于江苏科技大学网站的补丁与工具。

当前为 2022-01-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JUST Kit
  3. // @description Patches & tools for JUST Website.
  4. // @description:zh-CN 用于江苏科技大学网站的补丁与工具。
  5. // @namespace https://greasyfork.org/users/197529
  6. // @version 0.1.28
  7. // @author kkocdko
  8. // @license Unlicense
  9. // @match *://*.just.edu.cn/*
  10. // @match *://*.just.edu.cn:8080/*
  11. // @match *://10.250.255.34/*
  12. // @match *://202.195.195.198/*
  13. // @match *://202.195.206.36:8080/*
  14. // @match *://202.195.206.37:8080/*
  15. // ==/UserScript==
  16. "use strict";
  17.  
  18. const { addFloatButton, waitValue, saveStr } = {
  19. addFloatButton(text, onClick) /* 20200707-1237 */ {
  20. if (!document.addFloatButton) {
  21. const container = document.body
  22. .appendChild(document.createElement("div"))
  23. .attachShadow({ mode: "open" });
  24. container.innerHTML =
  25. "<style>:host{position:fixed;top:3px;left:3px;z-index:2147483647;height:0}#i{display:none}*{float:left;margin:4px;padding:1em;outline:0;border:0;border-radius:5px;background:#1e88e5;box-shadow:0 1px 4px rgba(0,0,0,.1);color:#fff;font-size:14px;line-height:0;transition:.3s}:active{background:#42a5f5;box-shadow:0 2px 5px rgba(0,0,0,.2)}button:active{transition:0s}:checked~button{visibility:hidden;opacity:0;transform:translateY(-3em)}label{border-radius:50%}:checked~label{opacity:.3;transform:translateY(3em)}</style><input id=i type=checkbox><label for=i></label>";
  26. document.addFloatButton = (text, onClick) => {
  27. const button = document.createElement("button");
  28. button.textContent = text;
  29. button.addEventListener("click", onClick);
  30. return container.appendChild(button);
  31. };
  32. }
  33. return document.addFloatButton(text, onClick);
  34. },
  35. waitValue(fn, interval = 200, timeout = 3000) /* 20220104-1405 */ {
  36. return new Promise((resolve, reject) => {
  37. const intervalHandle = setInterval(() => {
  38. try {
  39. const value = fn();
  40. if (!value) return;
  41. clearInterval(intervalHandle);
  42. clearTimeout(timeoutHandle);
  43. resolve(value);
  44. } catch {}
  45. }, interval);
  46. const timeoutHandle = setTimeout(() => {
  47. clearInterval(intervalHandle);
  48. reject("waitValue: timeout");
  49. }, timeout);
  50. });
  51. },
  52. saveStr(name, str) /* 20211203-1130 */ {
  53. const el = document.createElement("a");
  54. el.download = name;
  55. el.href = URL.createObjectURL(new Blob([str]));
  56. el.click();
  57. },
  58. };
  59.  
  60. // Styles
  61. document.lastChild.appendChild(document.createElement("style")).textContent = `
  62. body { overflow-x: auto; }
  63. #browserPrompt { display: none; }
  64. input.button { background-color: #07e; }
  65. .checked .iCheck-helper { background: none; border: solid #22645e; border-radius: 50%; opacity: 1; }
  66. `.replace(/;/g, "!important;");
  67.  
  68. // Force page to scroll on x axis
  69. waitValue(() => document.readyState !== "loading").then(() => {
  70. if (top !== self || document.documentElement.offsetWidth >= 1280) return;
  71. addFloatButton("Scroll X Axis", () => {
  72. document.documentElement.style.cssText +=
  73. "min-width: 1280px !important; overflow-x: scroll !important";
  74. });
  75. });
  76.  
  77. // Auto login
  78. if (location.pathname.endsWith("/login"))
  79. setTimeout(() => document.querySelector(".login_btn").click(), 100);
  80.  
  81. // Fix P.E. page left panel
  82. if (location.pathname.endsWith("/menu.asp")) {
  83. setTimeout(() => {
  84. for (const el of document.querySelectorAll("[onclick]")) {
  85. const v = el.getAttribute("onclick").replace("href(", "href=(");
  86. el.setAttribute("onclick", v);
  87. }
  88. }, 900);
  89. }
  90.  
  91. // Health clock in
  92. if (location.pathname.endsWith("/jkxxtb/jkxxcj.jsp")) {
  93. addFloatButton("Clock in", () => {
  94. input_tw.value = input_zwtw.value = 36;
  95. post.click();
  96. });
  97. }
  98.  
  99. // Schedule dump
  100. if (location.pathname.endsWith("/xskb_list.do")) {
  101. addFloatButton("Dump schedule", () => {
  102. saveStr(
  103. `schedule_${zc.value}_${Date.now().toString(36).slice(0, -2)}.html`,
  104. `<!DOCTYPE html><meta name="viewport" content="width=device-width">` +
  105. kbtable.outerHTML
  106. );
  107. });
  108. }
  109.  
  110. // Teaching Evaluation
  111. if (location.pathname.endsWith("/xspj_edit.do")) {
  112. addFloatButton("Fill form", () => {
  113. for (const el of document.querySelectorAll("[type=radio]:first-child"))
  114. el.click();
  115. document.querySelector("[type=radio]:not(:first-child)").click();
  116. });
  117. }
  118.  
  119. // GPA Estimation
  120. // https://github.com/mikai233/fstar-client/blob/e387e2948f158968e01d0497375ef60faccc589e/lib/utils/utils.dart
  121. // if (location.pathname.endsWith("/cjcx_list")) {
  122. // addFloatButton("Estimate GPA", () => {});
  123. // }
  124.  
  125. // Fix `window.showModalDialog`
  126. (this.unsafeWindow || this).showModalDialog = async (url, args, opt = "") => {
  127. // Thanks for github.com/niutech/showModalDialog
  128. const dialog = document.body.appendChild(document.createElement("dialog"));
  129. dialog.style = `padding:0;${opt.replace(/dialog/gi, "")}`;
  130. const iframe = dialog.appendChild(document.createElement("iframe"));
  131. iframe.style = "width:100%;height:100%;border:0";
  132. iframe.src = url;
  133. dialog.showModal();
  134. await new Promise((r) => (iframe.onload = r));
  135. iframe.contentWindow.close = () => dialog.remove();
  136. iframe.contentWindow.dialogArguments = args;
  137. };
  138.  
  139. // Free WLAN?
  140. // (this.unsafeWindow || self).XMLHttpRequest = new Proxy(XMLHttpRequest, {
  141. // construct: (T, args) => {
  142. // const ret = new T(...args);
  143. // let inner = null;
  144. // Object.defineProperty(ret, "onreadystatechange", {
  145. // value(...args) {
  146. // if (ret.readyState == 4 &&ret.responseURL === "http://10.250.255.34/api/v1/login") {}
  147. // if (inner) inner(...args);
  148. // },
  149. // set: (n) => (inner = n),
  150. // });
  151. // return ret;
  152. // },
  153. // });
  154. // if (property == "responseText" && target.responseURL === "http://10.250.255.34/api/v1/login") {
  155. // const json = JSON.parse(target.responseText);
  156. // if (json?.data?.policy?.pagenumb === "mondaypage") {
  157. // json.data.policy.channels.push({ name: "XSWK", id: "1" });
  158. // target.responseText = JSON.stringify(json);
  159. // }
  160. // let b = target.responseText;
  161. // let a = `{"code":200,"message":"ok","data":{"reauth":true,"policy":{"pagenumb":"mondaypage","channels":[{"name":"中国移动","id":"2"},{"name":"中国电信","id":"3"},{"name":"中国联通","id":"4"}]}}}`;
  162. // }
  163.  
  164. /* ===== Notes ===== *
  165.  
  166. 个人主页:my.just.edu.cn
  167. VPN2反代:vpn2.just.edu.cn
  168. 360SO via VPN2:client.v.just.edu.cn/https/webvpnb153e15136e234229309c84507966ea4
  169. 教务系统(自动登录):jwgl.just.edu.cn:8080/sso.jsp
  170. 后勤:hqgy.just.edu.cn/sg/wechat/index.jsp
  171. 查寝分数:hqgy.just.edu.cn/sg/wechat/healthCheck.jsp
  172. 健康打卡:ehall.just.edu.cn/default/work/jkd/jkxxtb/jkxxcj.jsp
  173. 体育:tyxy.just.edu.cn
  174. 网课:teach.just.edu.cn
  175. 实验课成绩:202.195.195.198/sy/
  176. 退出登录:ids2.just.edu.cn/cas/logout
  177. 智慧树:http://portals.zhihuishu.com/just
  178. 超星:http://just.fanya.chaoxing.com
  179. 安全微伴:https://weiban.mycourse.cn/pharos/login/jskjdx/21200002/loginByJskjdx.do
  180.  
  181. 教务系统内网:
  182. http://202.195.206.36:8080/jsxsd
  183. http://202.195.206.37:8080/jsxsd
  184.  
  185. 奇怪的管理界面:
  186. https://client.v.just.edu.cn/enlink/#/client/app
  187.  
  188. VPN2 使用笔记:
  189. 使用 `360SO via VPN2` 搜索要访问的网址,记得加上 `http / https` 前缀。
  190. 搜索结果页出现“找不到该 URL,可以直接访问 `http://x.x`”后点击直接访问链接即可。
  191. 若遇到“无效网关”等奇怪错误,请检查协议前缀是否正确,如 http 可能误写为 https。
  192. 当前(20220110)VPN2 似乎不支持流式传输,因而下载大文件可能出错,记得校验 Hash。
  193.  
  194. /* ================= */