JUST Kit

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

当前为 2022-04-19 提交的版本,查看 最新版本

  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.60
  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, saveStr } = {
  19. addFloatButton(text, onclick) /* 20220419-1455 */ {
  20. if (!document.addFloatButton) {
  21. const host = document.body.appendChild(document.createElement("div"));
  22. const root = host.attachShadow({ mode: "open" });
  23. root.innerHTML = `<style>:host{position:fixed;top:4px;left:4px;z-index:2147483647;height:0}#i{display:none}*{float:left;padding:1em;margin:4px;font-size:14px;line-height:0;color:#fff;user-select:none;background:#28e;border:1px solid #fffa;border-radius:8px;transition:.3s}[for]~:active{background:#4af;transition:0s}:checked~*{opacity:.3;transform:translateY(-3em)}:checked+*{transform:translateY(3em)}</style><input id=i type=checkbox><label for=i>`;
  24. document.addFloatButton = (text, onclick) => {
  25. const el = document.createElement("label");
  26. el.textContent = text;
  27. el.addEventListener("click", onclick);
  28. return root.appendChild(el);
  29. };
  30. }
  31. return document.addFloatButton(text, onclick);
  32. },
  33. saveStr(name, str) /* 20211203-1130 */ {
  34. const el = document.createElement("a");
  35. el.download = name;
  36. el.href = URL.createObjectURL(new Blob([str]));
  37. el.click();
  38. },
  39. };
  40.  
  41. const urlMatch = /* match url prefix, supports webvpn */ ([s]) =>
  42. location.href.match(/(?<=:..+)\/(?!http|webvpn).+/)[0].startsWith(s);
  43.  
  44. // Styles
  45. document.lastChild.appendChild(document.createElement("style")).textContent = `
  46. input.button { background-color: #07e; }
  47. .iradio_square-green.checked { box-shadow: inset 0 0 4px; border-radius: 50%; }
  48. `.replace(/;/g, "!important;");
  49.  
  50. // Force page to scroll on x axis
  51. if (
  52. top === self &&
  53. (urlMatch`/_s2/students_` || urlMatch`/TeachingCenterStudentWeb`)
  54. ) {
  55. document.documentElement.style.cssText +=
  56. ";min-width: 1280px !important; overflow-x: auto !important;";
  57. }
  58.  
  59. // Auto login
  60. if (urlMatch`/cas/login`) {
  61. setInterval(() => {
  62. if (!rememberPassword.checked) return;
  63. const el = document.querySelector(".login_btn");
  64. el.click();
  65. el.click = () => {};
  66. }, 100);
  67. }
  68.  
  69. // Fix P.E. page left panel
  70. if (urlMatch`/menu.asp?menu`) {
  71. setTimeout(() => {
  72. for (const el of document.querySelectorAll("[onclick]")) {
  73. const v = el.getAttribute("onclick").replace("href(", "href=(");
  74. el.setAttribute("onclick", v);
  75. }
  76. }, 900);
  77. }
  78.  
  79. // Health check in (old)
  80. if (urlMatch`/default/work/jkd/jkxxtb/jkxxcj.jsp`) {
  81. addFloatButton("Check in", () => {
  82. input_tw.value = input_zwtw.value = 36;
  83. post.click();
  84. });
  85. }
  86.  
  87. // Health check in
  88. if (urlMatch`/static/?health-check-in`) {
  89. document.head.innerHTML += `<meta name=viewport content="width=device-width"><style>body{margin:0}iframe{border:0;width:100%;height:100%}</style>`;
  90. document.body.innerHTML = `<iframe src=../jkdk.html></iframe>`;
  91. document.title = "just-kit-health-check-in";
  92. const key = document.title + "-location";
  93. addFloatButton("Check in", () => {
  94. const iframe = document.querySelector("iframe").contentWindow.document;
  95. const el = iframe.querySelector("input[placeholder$=定位]");
  96. el.value = localStorage[key];
  97. el._valueTracker.setValue(""); // github.com/facebook/react/issues/11488#issuecomment-347775628
  98. el.dispatchEvent(new Event("input", { bubbles: true }));
  99. setTimeout(() => iframe.querySelector("form+*>*").click());
  100. });
  101. addFloatButton(`Location = ${localStorage[key]}`, function () {
  102. localStorage[key] = prompt(key, localStorage[key]);
  103. this.textContent = `Location = ${localStorage[key]}`;
  104. });
  105. // encrypt=(v,k)=>CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(v),CryptoJS.MD5(k),{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7}).toString()
  106. }
  107.  
  108. // Schedule dump
  109. if (urlMatch`/jsxsd/xskb/xskb_list.do`) {
  110. addFloatButton("Dump schedule", () => {
  111. const date = Date.now().toString(36).slice(0, -2);
  112. const name = `schedule_${zc.value || 0}_${date}.html`;
  113. const prefix = `<!DOCTYPE html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><style>body{margin:2px -1px;font-family:sans-serif}table{border:0}</style>`;
  114. const content = prefix + kbtable.outerHTML;
  115. document.documentElement.innerHTML = content;
  116. document.title = name;
  117. saveStr(name, content);
  118. });
  119. }
  120.  
  121. // Teaching evaluation
  122. if (urlMatch`/jsxsd/xspj/xspj_edit.do`) {
  123. addFloatButton("Fill form", () => {
  124. for (const el of document.querySelectorAll("[type=radio]:first-child"))
  125. el.click();
  126. document.querySelector("[type=radio]:not(:first-child)").click();
  127. });
  128. }
  129.  
  130. // Fix `window.showModalDialog`
  131. (this.unsafeWindow || this).showModalDialog = (url) => open(url);
  132.  
  133. // GPA Estimation
  134. // github.com/mikai233/fstar-client/blob/e387e2948f158968e01d0497375ef60faccc589e/lib/utils/utils.dart
  135. // if (location.pathname.endsWith("/cjcx_list")) {
  136. // addFloatButton("Estimate GPA", () => {});
  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. // http://www.gaoxiaokaoshi.com/Study/LibraryStudyList.aspx
  165. // const grid=document.body.appendChild(document.createElement('parallel-grid'))
  166. // grid.style="display:grid;grid:1fr 1fr 1fr 1fr/ 1fr 1fr 1fr;width:100vw;height:100vh"
  167. // showframe=(p_Name, p_Id)=>{grid.appendChild(document.createElement('iframe')).src="../Study/LibraryStudy.aspx?tmp=1&Id=" + p_Id + "&PlanId=" + ddlClass.value}
  168.  
  169. /* ===== Notes ===== *
  170.  
  171. 个人主页: my.just.edu.cn
  172. VPN2反代: vpn2.just.edu.cn
  173. 360SO VPN2: client.v.just.edu.cn/https/webvpnb153e15136e234229309c84507966ea4
  174. 教务管理: jwgl.just.edu.cn:8080/jsxsd/
  175. 教务管理(单点登录): jwgl.just.edu.cn:8080/sso.jsp
  176. 教务管理(内网1): 202.195.206.36:8080/jsxsd
  177. 教务管理(内网2): 202.195.206.37:8080/jsxsd
  178. 后勤管理: hqgy.just.edu.cn/sg/wechat/index.jsp
  179. 查寝得分: hqgy.just.edu.cn/sg/wechat/healthCheck.jsp
  180. 健康打卡: dc.just.edu.cn/static/?health-check-in
  181. 健康打卡(RAW): dc.just.edu.cn/jkdk.html
  182. 健康打卡(旧): ehall.just.edu.cn/default/work/jkd/jkxxtb/jkxxcj.jsp
  183. 体育: tyxy.just.edu.cn
  184. 网课: teach.just.edu.cn
  185. 实验课成绩: 202.195.195.198/sy/
  186. 退出登录: ids2.just.edu.cn/cas/logout
  187. 奇怪的管理界面: client.v.just.edu.cn/enlink/#/client/app
  188. 智慧树: portals.zhihuishu.com/just
  189. 超星: just.fanya.chaoxing.com
  190. 安全微伴: weiban.mycourse.cn/pharos/login/jskjdx/21200002/loginByJskjdx.do
  191. 国防教育: www.gaoxiaokaoshi.com
  192.  
  193. 关于 [ VPN2 ] :
  194. 使用 `360SO via VPN2` 搜索要访问的网址。记得加上 `http / https` 前缀。
  195. 搜索结果页出现“找不到该 URL,可以直接访问 `http://x.x`”后点击直接访问链接即可。
  196. 遇“无效网关”等奇怪错误时,请检查协议前缀是否正确,如 http 可能误写为 https。
  197. 当前(20220110)VPN2 似乎不支持流式传输,因而下载大文件可能出错,记得校验 Hash。
  198.  
  199. 关于 [ 健康打卡 ] :
  200. 新版(20220420)健康打卡报表使用 Hash Router,各跳转关系十分混乱且不稳定。
  201. 为简化实现,当且仅当访问上文指定的地址时才可使用一键打卡功能。
  202.  
  203. /* ================= */