JUST Kit

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

目前为 2022-03-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.42
  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) /* 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. saveStr(name, str) /* 20211203-1130 */ {
  36. const el = document.createElement("a");
  37. el.download = name;
  38. el.href = URL.createObjectURL(new Blob([str]));
  39. el.click();
  40. },
  41. };
  42.  
  43. const urlMatch = /* match url prefix, supports webvpn */ ([s]) =>
  44. location.href.match(/(?<=:..+)\/(?!http|webvpn).+/)[0].startsWith(s);
  45.  
  46. // Styles
  47. document.lastChild.appendChild(document.createElement("style")).textContent = `
  48. input.button { background-color: #07e; }
  49. .checked .iCheck-helper { background: none; border: solid #22645e; border-radius: 50%; opacity: 1; }
  50. `.replace(/;/g, "!important;");
  51.  
  52. // Force page to scroll on x axis
  53. if (
  54. top === self &&
  55. (urlMatch`/_s2/students_` || urlMatch`/TeachingCenterStudentWeb`)
  56. ) {
  57. document.documentElement.style.cssText +=
  58. ";min-width: 1280px !important; overflow-x: auto !important;";
  59. }
  60.  
  61. // Auto login
  62. if (urlMatch`/cas/login`) {
  63. setTimeout(() => document.querySelector(".login_btn").click(), 100);
  64. }
  65.  
  66. // Fix P.E. page left panel
  67. if (urlMatch`/menu.asp?menu`) {
  68. setTimeout(() => {
  69. for (const el of document.querySelectorAll("[onclick]")) {
  70. const v = el.getAttribute("onclick").replace("href(", "href=(");
  71. el.setAttribute("onclick", v);
  72. }
  73. }, 900);
  74. }
  75.  
  76. // Health clock in
  77. if (urlMatch`/default/work/jkd/jkxxtb/jkxxcj.jsp`) {
  78. addFloatButton("Clock in", () => {
  79. input_tw.value = input_zwtw.value = 36;
  80. post.click();
  81. });
  82. }
  83.  
  84. // Schedule dump
  85. if (urlMatch`/jsxsd/xskb/xskb_list.do`) {
  86. addFloatButton("Dump schedule", () => {
  87. const date = Date.now().toString(36).slice(0, -2);
  88. const name = `schedule_${zc.value || 0}_${date}.html`;
  89. const content =
  90. `<!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>` +
  91. kbtable.outerHTML;
  92. document.documentElement.innerHTML = content;
  93. document.title = name;
  94. saveStr(name, content);
  95. });
  96. }
  97.  
  98. // Teaching evaluation
  99. if (urlMatch`/jsxsd/xspj/xspj_edit.do`) {
  100. addFloatButton("Fill form", () => {
  101. for (const el of document.querySelectorAll("[type=radio]:first-child"))
  102. el.click();
  103. document.querySelector("[type=radio]:not(:first-child)").click();
  104. });
  105. }
  106.  
  107. // Fix `window.showModalDialog`
  108. (this.unsafeWindow || this).showModalDialog = (url) => open(url);
  109.  
  110. // GPA Estimation
  111. // https://github.com/mikai233/fstar-client/blob/e387e2948f158968e01d0497375ef60faccc589e/lib/utils/utils.dart
  112. // if (location.pathname.endsWith("/cjcx_list")) {
  113. // addFloatButton("Estimate GPA", () => {});
  114. // }
  115.  
  116. // Free WLAN?
  117. // (this.unsafeWindow || self).XMLHttpRequest = new Proxy(XMLHttpRequest, {
  118. // construct: (T, args) => {
  119. // const ret = new T(...args);
  120. // let inner = null;
  121. // Object.defineProperty(ret, "onreadystatechange", {
  122. // value(...args) {
  123. // if (ret.readyState == 4 &&ret.responseURL === "http://10.250.255.34/api/v1/login") {}
  124. // if (inner) inner(...args);
  125. // },
  126. // set: (n) => (inner = n),
  127. // });
  128. // return ret;
  129. // },
  130. // });
  131. // if (property == "responseText" && target.responseURL === "http://10.250.255.34/api/v1/login") {
  132. // const json = JSON.parse(target.responseText);
  133. // if (json?.data?.policy?.pagenumb === "mondaypage") {
  134. // json.data.policy.channels.push({ name: "XSWK", id: "1" });
  135. // target.responseText = JSON.stringify(json);
  136. // }
  137. // let b = target.responseText;
  138. // let a = `{"code":200,"message":"ok","data":{"reauth":true,"policy":{"pagenumb":"mondaypage","channels":[{"name":"中国移动","id":"2"},{"name":"中国电信","id":"3"},{"name":"中国联通","id":"4"}]}}}`;
  139. // }
  140.  
  141. // http://www.gaoxiaokaoshi.com/Study/LibraryStudyList.aspx
  142. // const grid=document.body.appendChild(document.createElement('parallel-grid'))
  143. // grid.style="display:grid;grid:1fr 1fr 1fr 1fr/ 1fr 1fr 1fr;width:100vw;height:100vh"
  144. // showframe=(p_Name, p_Id)=>{grid.appendChild(document.createElement('iframe')).src="../Study/LibraryStudy.aspx?tmp=1&Id=" + p_Id + "&PlanId=" + ddlClass.value}
  145.  
  146. /* ===== Notes ===== *
  147.  
  148. 个人主页:my.just.edu.cn
  149. VPN2反代:vpn2.just.edu.cn
  150. 360SO via VPN2:client.v.just.edu.cn/https/webvpnb153e15136e234229309c84507966ea4
  151. 教务管理:jwgl.just.edu.cn:8080/jsxsd/
  152. 教务管理(单点登录):jwgl.just.edu.cn:8080/sso.jsp
  153. 教务管理(内网1):202.195.206.36:8080/jsxsd
  154. 教务管理(内网2):202.195.206.37:8080/jsxsd
  155. 后勤管理:hqgy.just.edu.cn/sg/wechat/index.jsp
  156. 查寝得分:hqgy.just.edu.cn/sg/wechat/healthCheck.jsp
  157. 健康打卡:ehall.just.edu.cn/default/work/jkd/jkxxtb/jkxxcj.jsp
  158. 体育:tyxy.just.edu.cn
  159. 网课:teach.just.edu.cn
  160. 实验课成绩:202.195.195.198/sy/
  161. 退出登录:ids2.just.edu.cn/cas/logout
  162. 奇怪的管理界面:client.v.just.edu.cn/enlink/#/client/app
  163. 智慧树:portals.zhihuishu.com/just
  164. 超星:just.fanya.chaoxing.com
  165. 安全微伴:weiban.mycourse.cn/pharos/login/jskjdx/21200002/loginByJskjdx.do
  166. 国防教育:www.gaoxiaokaoshi.com
  167.  
  168. VPN2 使用笔记:
  169. 使用 `360SO via VPN2` 搜索要访问的网址,记得加上 `http / https` 前缀。
  170. 搜索结果页出现“找不到该 URL,可以直接访问 `http://x.x`”后点击直接访问链接即可。
  171. 若遇到“无效网关”等奇怪错误,请检查协议前缀是否正确,如 http 可能误写为 https。
  172. 当前(20220110)VPN2 似乎不支持流式传输,因而下载大文件可能出错,记得校验 Hash。
  173.  
  174. /* ================= */