JUST Kit

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

当前为 2023-02-27 提交的版本,查看 最新版本

  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.2.2
  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. // Schedule dump
  114. if (urlMatch`/jwglxt/kbcx/xskbcx_cxXskbcxIndex.html`) {
  115. addFloatButton("Better schedule", () => {
  116. let v = Math.floor(
  117. (Date.now() - new Date("2023-02-20 00:00:00 +8").getTime()) /
  118. 1000 /
  119. 3600 /
  120. 24 /
  121. 7 +
  122. 1
  123. );
  124. v = +prompt("Week = ", v);
  125.  
  126. if (v !== 0)
  127. document
  128. .querySelectorAll("#kblist_table .glyphicon-calendar")
  129. .forEach((el) => {
  130. let arr = [...el.nextSibling.textContent.matchAll(/\d+-?\d*/g)]
  131. .map((v) => v[0])
  132. .map((t) => (t.includes("-") ? t : t + "-" + t))
  133. .map((v) => v.split("-").map((n) => +n));
  134. for (const [from, to] of arr) {
  135. if (from <= v && v <= to) {
  136. return;
  137. }
  138. }
  139. el.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
  140. });
  141. document
  142. .querySelectorAll(
  143. "#kblist_table>tbody>tr:not(:first-child)>td:first-child"
  144. )
  145. .forEach((el) => {
  146. el.setAttribute("rowspan", "1");
  147. });
  148. document.querySelectorAll(".timetable .week").forEach((el) => {
  149. el.textContent = el.textContent.slice(2);
  150. });
  151. document.querySelector("#kblist_table .pull-left").nextSibling.remove();
  152. document.querySelector("#kblist_table .pull-left").nextSibling.remove();
  153. document.querySelector('button[href="#table2"]').click();
  154. document
  155. .querySelectorAll(
  156. "#kblist_table .glyphicon-tower, #kblist_table .glyphicon-home"
  157. )
  158. .forEach((el) => {
  159. el.nextSibling.remove();
  160. el.remove();
  161. });
  162. document.querySelectorAll("#kblist_table .glyphicon").forEach((el) => {
  163. el.remove();
  164. });
  165. document.querySelectorAll("#kblist_table td p>font").forEach((el) => {
  166. el.textContent = el.textContent.replace(/^.*?[::]/, " ");
  167. });
  168. document.querySelectorAll(".timetable .week").forEach((el) => {
  169. el.parentNode.width = 24;
  170. });
  171. document.querySelectorAll(".timetable .festival").forEach((el) => {
  172. el.parentNode.width = 34;
  173. });
  174. document.lastChild.appendChild(
  175. document.createElement("style")
  176. ).textContent = `
  177. .timetable .timetable_con { padding: 4px 4px; overflow: hidden;}
  178. .table-bordered,.table>tbody+tbody {border:none;}
  179. .table-bordered>thead>tr>th, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>tbody>tr>td, .table-bordered>tfoot>tr>td { border:1px solid #555; border-width: 1px 0 0 0;}
  180. .timetable .week,.timetable .festival{color:#000;}
  181. .timetable .festival{white-space: nowrap;}
  182. .timetable .timetable_con .title { width: 14em; margin-right: 2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
  183. .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td { padding: 0;}
  184. #table2{ background: #fff; position: fixed; left: 0; top: 0; width: 100vw; overflow: scroll; height: 100vh;}
  185. #table2 font[color="blue"]{color: #000;}*{ font-weight: normal; font-size:16px;font-family: sans-serif;}
  186. .timetable .week{padding:0 4px 0 0;}
  187. `.replace(/;/g, "!important;");
  188. });
  189. }
  190.  
  191. // Teaching evaluation
  192. if (urlMatch`/jsxsd/xspj/xspj_edit.do`) {
  193. addFloatButton("Fill form", () => {
  194. for (const el of document.querySelectorAll("[type=radio]:first-child"))
  195. el.click();
  196. document.querySelector("[type=radio]:not(:first-child)").click();
  197. });
  198. }
  199.  
  200. // Fix `window.showModalDialog`
  201. (this.unsafeWindow || this).showModalDialog = (url) => open(url);
  202.  
  203. // GPA Estimation
  204. // github.com/mikai233/fstar-client/blob/e387e2948f158968e01d0497375ef60faccc589e/lib/utils/utils.dart
  205. // if (location.pathname.endsWith("/cjcx_list")) {
  206. // addFloatButton("Estimate GPA", () => {});
  207. // }
  208.  
  209. // Free WLAN?
  210. // (this.unsafeWindow || self).XMLHttpRequest = new Proxy(XMLHttpRequest, {
  211. // construct: (T, args) => {
  212. // const ret = new T(...args);
  213. // let inner = null;
  214. // Object.defineProperty(ret, "onreadystatechange", {
  215. // value(...args) {
  216. // if (ret.readyState == 4 &&ret.responseURL === "http://10.250.255.34/api/v1/login") {}
  217. // if (inner) inner(...args);
  218. // },
  219. // set: (n) => (inner = n),
  220. // });
  221. // return ret;
  222. // },
  223. // });
  224. // if (property == "responseText" && target.responseURL === "http://10.250.255.34/api/v1/login") {
  225. // const json = JSON.parse(target.responseText);
  226. // if (json?.data?.policy?.pagenumb === "mondaypage") {
  227. // json.data.policy.channels.push({ name: "XSWK", id: "1" });
  228. // target.responseText = JSON.stringify(json);
  229. // }
  230. // let b = target.responseText;
  231. // let a = `{"code":200,"message":"ok","data":{"reauth":true,"policy":{"pagenumb":"mondaypage","channels":[{"name":"中国移动","id":"2"},{"name":"中国电信","id":"3"},{"name":"中国联通","id":"4"}]}}}`;
  232. // }
  233.  
  234. // http://www.gaoxiaokaoshi.com/Study/LibraryStudyList.aspx
  235. // const grid=document.body.appendChild(document.createElement('parallel-grid'))
  236. // grid.style="display:grid;grid:1fr 1fr 1fr 1fr/ 1fr 1fr 1fr;width:100vw;height:100vh"
  237. // showframe=(p_Name, p_Id)=>{grid.appendChild(document.createElement('iframe')).src="../Study/LibraryStudy.aspx?tmp=1&Id=" + p_Id + "&PlanId=" + ddlClass.value}
  238.  
  239. /* ===== Notes ===== *
  240.  
  241. 个人主页: my.just.edu.cn
  242. VPN2反代: vpn2.just.edu.cn
  243. 360SO VPN2: client.v.just.edu.cn/https/webvpnb153e15136e234229309c84507966ea4
  244. 教务: jwgl.just.edu.cn:8080/jsxsd/
  245. 教务(单点登录): jwgl.just.edu.cn:8080/sso.jsp
  246. 教务(内网1): 202.195.206.36:8080/jsxsd
  247. 教务(内网2): 202.195.206.37:8080/jsxsd
  248. 财务: 218.3.134.246/WFManager/login.jsp
  249. 后勤: hqgy.just.edu.cn/sg/wechat/index.jsp
  250. 查寝得分: hqgy.just.edu.cn/sg/wechat/healthCheck.jsp
  251. 健康打卡: dc.just.edu.cn/static/?health-check-in
  252. 健康打卡(RAW): dc.just.edu.cn/jkdk.html
  253. 健康打卡(旧): ehall.just.edu.cn/default/work/jkd/jkxxtb/jkxxcj.jsp
  254. 体育: tyxy.just.edu.cn
  255. 网课: teach.just.edu.cn
  256. 实验课成绩: 202.195.195.198/sy/
  257. 退出登录: ids2.just.edu.cn/cas/logout
  258. 奇怪的管理界面: client.v.just.edu.cn/enlink/#/client/app
  259. 智慧树: portals.zhihuishu.com/just
  260. 超星: just.fanya.chaoxing.com
  261. 安全微伴: weiban.mycourse.cn/pharos/login/jskjdx/21200002/loginByJskjdx.do
  262. 国防教育: www.gaoxiaokaoshi.com
  263.  
  264. 关于 [ VPN2 ] :
  265. 就如 URI 中所写的那样,VPN2 只是一个类似反向代理的玩意。
  266. 由于学校网站配置千奇百怪,有时会遇到只有在校园网中才能访问的情况。这时可以使用 VPN2。
  267. 使用 `360SO via VPN2` 搜索要访问的网址。记得加上 `http / https` 前缀。
  268. 搜索结果页出现“找不到该 URL,可以直接访问 `http://x.x`”后点击直接访问链接即可。
  269. 遇“无效网关”等奇怪错误时,请检查协议前缀是否正确,如 http 可能误写为 https。
  270. 当前(20220110)VPN2 似乎不支持流式传输,因而下载大文件可能出错,记得校验 Hash。
  271.  
  272. 关于 [ 健康打卡 ] :
  273. 新版(20220420)健康打卡报表使用 Hash Router,各跳转关系十分混乱且不稳定。
  274. 为简化实现,当且仅当访问上文指定的地址时才可使用一键打卡功能。
  275. 直接 Post 请求进行打卡的实现在本目录下的 health-check-in.js 中,感兴趣的可以尝试。
  276.  
  277. 如果 [ 教务系统提示 非法访问 ] :
  278. 相信自己,你并没有做错什么。这时候你可以清除 Cookie,SessionStorage 等数据。
  279. 当然 Cookie 会自动过期,所以和跳大神治麻疹一样,随便用点什么“独门秘籍”,过一阵子也就自己好了。
  280.  
  281. 如果 [ 密码错误 ] :
  282. 只需将 [ just123456, 123456, <身份证后六位> ] 排列组合即可。
  283.  
  284. 关于 [ 校园网 ] :
  285.  
  286. /* ================= */