JUST Kit

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

当前为 2022-05-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JUST Kit
  3. // @description Patches & tools for JUST Website.
  4. // @description:en Patches & tools for JUST Website.
  5. // @description:zh-CN 用于江苏科技大学网站的补丁与工具。
  6. // @namespace https://greasyfork.org/users/197529
  7. // @version 0.1.62
  8. // @author kkocdko
  9. // @license Unlicense
  10. // @match *://*.just.edu.cn/*
  11. // @match *://*.just.edu.cn:8080/*
  12. // @match *://10.250.255.34/*
  13. // @match *://202.195.195.198/*
  14. // @match *://202.195.206.36:8080/*
  15. // @match *://202.195.206.37:8080/*
  16. // ==/UserScript==
  17. "use strict";
  18.  
  19. const { addFloatButton, saveStr } = {
  20. addFloatButton(text, onclick) /* 20220509-1936 */ {
  21. if (!document.addFloatButton) {
  22. const host = document.body.appendChild(document.createElement("div"));
  23. const root = host.attachShadow({ mode: "open" });
  24. root.innerHTML = `<style>:host{position:fixed;top:4px;left:4px;z-index:2147483647;height:0}#i{display:none}*{float:left;padding:0 1em;margin:4px;font-size:14px;line-height:2em;color:#fff;user-select:none;background:#28e;border:1px solid #fffa;border-radius:8px;transition:.3s}[for]~:active{filter:brightness(1.1);transition:0s}:checked~*{opacity:.3;transform:translateY(-3em)}:checked+*{transform:translateY(3em)}</style><input id=i type=checkbox><label for=i>&zwj;</label>`;
  25. document.addFloatButton = (text, onclick) => {
  26. const el = document.createElement("label");
  27. el.textContent = text;
  28. el.addEventListener("click", onclick);
  29. return root.appendChild(el);
  30. };
  31. }
  32. return document.addFloatButton(text, onclick);
  33. },
  34. saveStr(name, str) /* 20211203-1130 */ {
  35. const el = document.createElement("a");
  36. el.download = name;
  37. el.href = URL.createObjectURL(new Blob([str]));
  38. el.click();
  39. },
  40. };
  41.  
  42. const urlMatch = /* match url prefix, supports webvpn */ ([s]) =>
  43. location.href.match(/(?<=:..+)\/(?!http|webvpn).+/)[0].startsWith(s);
  44.  
  45. // Styles
  46. document.lastChild.appendChild(document.createElement("style")).textContent = `
  47. input.button { background-color: #07e; }
  48. .iradio_square-green.checked { box-shadow: inset 0 0 4px; border-radius: 50%; }
  49. `.replace(/;/g, "!important;");
  50.  
  51. // Force page to scroll on x axis
  52. if (
  53. top === self &&
  54. (urlMatch`/_s2/students_` || urlMatch`/TeachingCenterStudentWeb`)
  55. ) {
  56. document.documentElement.style.cssText +=
  57. ";min-width: 1280px !important; overflow-x: auto !important;";
  58. }
  59.  
  60. // Auto login
  61. if (urlMatch`/cas/login`) {
  62. setInterval(() => {
  63. if (!rememberPassword.checked) return;
  64. const el = document.querySelector(".login_btn");
  65. el.click();
  66. el.click = () => {};
  67. }, 100);
  68. }
  69.  
  70. // Fix P.E. page left panel
  71. if (urlMatch`/menu.asp?menu`) {
  72. setTimeout(() => {
  73. for (const el of document.querySelectorAll("[onclick]")) {
  74. const v = el.getAttribute("onclick").replace("href(", "href=(");
  75. el.setAttribute("onclick", v);
  76. }
  77. }, 900);
  78. }
  79.  
  80. // Health check in
  81. if (urlMatch`/static/?health-check-in`) {
  82. document.head.innerHTML += `<meta name=viewport content="width=device-width"><style>body{margin:0}iframe{border:0;width:100%;height:100%}</style>`;
  83. document.body.innerHTML = `<iframe src=../jkdk.html></iframe>`;
  84. document.title = "just-kit-health-check-in";
  85. const key = document.title + "-location";
  86. addFloatButton("Check in", () => {
  87. const iframe = document.querySelector("iframe").contentWindow.document;
  88. const el = iframe.querySelector("input[placeholder$=定位]");
  89. el.value = localStorage[key];
  90. el._valueTracker.setValue(""); // github.com/facebook/react/issues/11488#issuecomment-347775628
  91. el.dispatchEvent(new Event("input", { bubbles: true }));
  92. setTimeout(() => iframe.querySelector("form+*>*").click());
  93. });
  94. addFloatButton(`Location = ${localStorage[key]}`, function () {
  95. localStorage[key] = prompt(key, localStorage[key]);
  96. this.textContent = `Location = ${localStorage[key]}`;
  97. });
  98. }
  99.  
  100. // Schedule dump
  101. if (urlMatch`/jsxsd/xskb/xskb_list.do`) {
  102. addFloatButton("Dump schedule", () => {
  103. const date = Date.now().toString(36).slice(0, -2);
  104. const name = `schedule_${zc.value || 0}_${date}.html`;
  105. 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>`;
  106. const content = prefix + kbtable.outerHTML;
  107. document.documentElement.innerHTML = content;
  108. document.title = name;
  109. saveStr(name, content);
  110. });
  111. }
  112.  
  113. // Teaching evaluation
  114. if (urlMatch`/jsxsd/xspj/xspj_edit.do`) {
  115. addFloatButton("Fill form", () => {
  116. for (const el of document.querySelectorAll("[type=radio]:first-child"))
  117. el.click();
  118. document.querySelector("[type=radio]:not(:first-child)").click();
  119. });
  120. }
  121.  
  122. // Fix `window.showModalDialog`
  123. (this.unsafeWindow || this).showModalDialog = (url) => open(url);
  124.  
  125. // GPA Estimation
  126. // github.com/mikai233/fstar-client/blob/e387e2948f158968e01d0497375ef60faccc589e/lib/utils/utils.dart
  127. // if (location.pathname.endsWith("/cjcx_list")) {
  128. // addFloatButton("Estimate GPA", () => {});
  129. // }
  130.  
  131. // Free WLAN?
  132. // (this.unsafeWindow || self).XMLHttpRequest = new Proxy(XMLHttpRequest, {
  133. // construct: (T, args) => {
  134. // const ret = new T(...args);
  135. // let inner = null;
  136. // Object.defineProperty(ret, "onreadystatechange", {
  137. // value(...args) {
  138. // if (ret.readyState == 4 &&ret.responseURL === "http://10.250.255.34/api/v1/login") {}
  139. // if (inner) inner(...args);
  140. // },
  141. // set: (n) => (inner = n),
  142. // });
  143. // return ret;
  144. // },
  145. // });
  146. // if (property == "responseText" && target.responseURL === "http://10.250.255.34/api/v1/login") {
  147. // const json = JSON.parse(target.responseText);
  148. // if (json?.data?.policy?.pagenumb === "mondaypage") {
  149. // json.data.policy.channels.push({ name: "XSWK", id: "1" });
  150. // target.responseText = JSON.stringify(json);
  151. // }
  152. // let b = target.responseText;
  153. // let a = `{"code":200,"message":"ok","data":{"reauth":true,"policy":{"pagenumb":"mondaypage","channels":[{"name":"中国移动","id":"2"},{"name":"中国电信","id":"3"},{"name":"中国联通","id":"4"}]}}}`;
  154. // }
  155.  
  156. // http://www.gaoxiaokaoshi.com/Study/LibraryStudyList.aspx
  157. // const grid=document.body.appendChild(document.createElement('parallel-grid'))
  158. // grid.style="display:grid;grid:1fr 1fr 1fr 1fr/ 1fr 1fr 1fr;width:100vw;height:100vh"
  159. // showframe=(p_Name, p_Id)=>{grid.appendChild(document.createElement('iframe')).src="../Study/LibraryStudy.aspx?tmp=1&Id=" + p_Id + "&PlanId=" + ddlClass.value}
  160.  
  161. /* ===== Notes ===== *
  162.  
  163. 个人主页: my.just.edu.cn
  164. VPN2反代: vpn2.just.edu.cn
  165. 360SO VPN2: client.v.just.edu.cn/https/webvpnb153e15136e234229309c84507966ea4
  166. 教务管理: jwgl.just.edu.cn:8080/jsxsd/
  167. 教务管理(单点登录): jwgl.just.edu.cn:8080/sso.jsp
  168. 教务管理(内网1): 202.195.206.36:8080/jsxsd
  169. 教务管理(内网2): 202.195.206.37:8080/jsxsd
  170. 后勤管理: hqgy.just.edu.cn/sg/wechat/index.jsp
  171. 查寝得分: hqgy.just.edu.cn/sg/wechat/healthCheck.jsp
  172. 健康打卡: dc.just.edu.cn/static/?health-check-in
  173. 健康打卡(RAW): dc.just.edu.cn/jkdk.html
  174. 健康打卡(旧): ehall.just.edu.cn/default/work/jkd/jkxxtb/jkxxcj.jsp
  175. 体育: tyxy.just.edu.cn
  176. 网课: teach.just.edu.cn
  177. 实验课成绩: 202.195.195.198/sy/
  178. 退出登录: ids2.just.edu.cn/cas/logout
  179. 奇怪的管理界面: client.v.just.edu.cn/enlink/#/client/app
  180. 智慧树: portals.zhihuishu.com/just
  181. 超星: just.fanya.chaoxing.com
  182. 安全微伴: weiban.mycourse.cn/pharos/login/jskjdx/21200002/loginByJskjdx.do
  183. 国防教育: www.gaoxiaokaoshi.com
  184.  
  185. 关于 [ VPN2 ] :
  186. 使用 `360SO via VPN2` 搜索要访问的网址。记得加上 `http / https` 前缀。
  187. 搜索结果页出现“找不到该 URL,可以直接访问 `http://x.x`”后点击直接访问链接即可。
  188. 遇“无效网关”等奇怪错误时,请检查协议前缀是否正确,如 http 可能误写为 https。
  189. 当前(20220110)VPN2 似乎不支持流式传输,因而下载大文件可能出错,记得校验 Hash。
  190.  
  191. 关于 [ 健康打卡 ] :
  192. 新版(20220420)健康打卡报表使用 Hash Router,各跳转关系十分混乱且不稳定。
  193. 为简化实现,当且仅当访问上文指定的地址时才可使用一键打卡功能。
  194.  
  195. /* ================= */