JUST EVO

Patches & tools for JUST Website

当前为 2021-09-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JUST EVO
  3. // @description Patches & tools for JUST Website
  4. // @namespace https://greasyfork.org/users/197529
  5. // @version 0.1.2
  6. // @author kkocdko
  7. // @license Unlicense
  8. // @match *://*.just.edu.cn/*
  9. // @noframes
  10. // ==/UserScript==
  11. "use strict";
  12.  
  13. const { addFloatButton, waitValue } = {
  14. addFloatButton(text, onClick) /* 20200707-1237 */ {
  15. if (!document.addFloatButton) {
  16. const container = document.body
  17. .appendChild(document.createElement("div"))
  18. .attachShadow({ mode: "open" });
  19. container.innerHTML =
  20. "<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>";
  21. document.addFloatButton = (text, onClick) => {
  22. const button = document.createElement("button");
  23. button.textContent = text;
  24. button.addEventListener("click", onClick);
  25. return container.appendChild(button);
  26. };
  27. }
  28. return document.addFloatButton(text, onClick);
  29. },
  30. waitValue(fn, interval = 200, timeout = 3000) /* 20210928-1143 */ {
  31. return new Promise((resolve, reject) => {
  32. const intervalHandle = setInterval(() => {
  33. try {
  34. const value = fn();
  35. if (!value) return;
  36. clearInterval(intervalHandle);
  37. clearTimeout(timeoutHandle);
  38. resolve(value);
  39. } catch {}
  40. }, interval);
  41. const timeoutHandle = setTimeout(() => {
  42. clearInterval(intervalHandle);
  43. reject();
  44. }, timeout);
  45. });
  46. },
  47. };
  48.  
  49. // Auto login
  50. waitValue(() => document.querySelector(".login_btn")).then((e) => e.click());
  51.  
  52. // Fix JUST P.E.
  53. waitValue(() => leftFrame.document.readyState === "complete").then(() => {
  54. leftFrame.document.querySelectorAll("[onclick]").forEach((el) => {
  55. const v = el.getAttribute("onclick").replace("href(", "href=(");
  56. el.setAttribute("onclick", v);
  57. });
  58. });