OJ.UZ enhancement

Enhances OJ.UZ

安装此脚本
作者推荐脚本

您可能也喜欢Send to VJudge

安装此脚本
  1. // ==UserScript==
  2. // @name OJ.UZ enhancement
  3. // @namespace ojuzenhancement
  4. // @version v5
  5. // @description Enhances OJ.UZ
  6. // @author EntityPlantt
  7. // @match https://oj.uz/*
  8. // @icon http://oj.uz/favicon.ico
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12. addEventListener("DOMContentLoaded", () => {
  13. setTheme();
  14. var style = document.createElement("style");
  15. style.innerHTML = `
  16. html.dark, .dark img, .dark iframe, .dark object { filter: invert(1) hue-rotate(180deg) }
  17. footer, body { background: #e9e9e9 }
  18. * {
  19. transition: none !important;
  20. -webkit-transition: none !important;
  21. -moz-transition: none !important;
  22. -o-transition: none !important;
  23. }
  24. .navbar { background: #daecda }
  25. .progressbar {
  26. background: #eee;
  27. box-shadow: none;
  28. height: 30px !important;
  29. }
  30. .progressbar .text {
  31. color: #333;
  32. top: -20px !important;
  33. }
  34. .progressbar > .bar { animation: progressbargradient 2s linear infinite; }
  35. #my-score canvas { animation: myscore_s 10s linear infinite, myscore_r 10s ease infinite; }
  36. .label {
  37. text-transform: uppercase;
  38. color: black !important;
  39. float: right;
  40. margin-left: .5em;
  41. }
  42. ul.footer-nav li a:hover { color: black !important; }
  43. footer p { color: #222; }
  44. @keyframes progressbargradient {
  45. from { background-position-x: 0% }
  46. to { background-position-x: 200% }
  47. }
  48. @keyframes myscore_s {
  49. from, to, 50% { scale: 1 }
  50. 25%, 75% { scale: 1.05 }
  51. }
  52. @keyframes myscore_r {
  53. from, to { transform: rotate(-10deg) }
  54. 50% { transform: rotate(10deg) }
  55. }
  56. body::-webkit-scrollbar { width: 15px; height: 15px }
  57. body::-webkit-scrollbar-track { background: #222 }
  58. body::-webkit-scrollbar-thumb { background: #444; border-radius: 7.5px }
  59. `;
  60. document.querySelector("head").appendChild(style);
  61. function setProgressBars() {
  62. document.querySelectorAll(".progressbar > .bar").forEach(elm => {
  63. let hue = parseFloat(elm.style.width.substring(0, elm.style.width.length - 1)) * 1.2;
  64. elm.style.background = `linear-gradient(90deg, hsl(${hue}, 57%, 53%), hsl(${hue}, 83%, 60%), hsl(${hue}, 57%, 53%))`;
  65. elm.style.backgroundSize = "200%";
  66. });
  67. requestAnimationFrame(setProgressBars);
  68. }
  69. setProgressBars();
  70. if (document.getElementById("my-score")) {
  71. var score = document.getElementById("my-score").parentElement.nextElementSibling.querySelector("td").innerText.split(" / ").map(x => parseInt(x));
  72. document.querySelector("#my-score canvas").style.filter = `hue-rotate(-${(1 - score[0] / score[1]) * 90}deg)`;
  73. document.getElementById("my-score").parentElement.style.background = `hsl(${score[0] / score[1] * 90}, 57%, 95%)`;
  74. }
  75. let li = document.createElement("li");
  76. li.className = "divider";
  77. document.querySelector(".login-bar").prepend(li);
  78. document.querySelector(".login-bar").prepend(document.createTextNode("\n"));
  79. li = document.createElement("li");
  80. li.innerHTML = "<a href='javascript:toggleTheme()'>Toggle theme</a>";
  81. document.querySelector(".login-bar").prepend(li);
  82. window.toggleTheme = () => void(localStorage.dark = document.body.parentElement.classList.toggle("dark"));
  83. addEventListener("storage", setTheme);
  84. if (Math.random() < .03) document.querySelector(".search-side li:last-child a").innerText = "Spanish";
  85. document.querySelector(".page-banner").remove();
  86. });
  87. function setTheme() {
  88. if (localStorage.dark == "true") document.body.parentElement.classList.add("dark");
  89. else document.body.parentElement.classList.remove("dark");
  90. }