vjudge+background

为vJudge设置背景

目前为 2023-08-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name vjudge+background
  3. // @namespace vjudge-plus-v2
  4. // @version 1.7
  5. // @description 为vJudge设置背景
  6. // @author axototl (original by Suntra)
  7. // @match https://vjudge.net/
  8. // @match https://vjudge.net/*
  9. // @noframes
  10. // @icon https://vjudge.net/favicon.ico
  11. // @run-at document-body
  12. // @license AGPLv3
  13. // @grant GM_addStyle
  14. // @grant GM_registerMenuCommand
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @run-at document-idle
  18. // ==/UserScript==
  19.  
  20. function reloader() {
  21. alert("设置成功,刷新生效");
  22. if (!navigator.onLine) {
  23. alert("离线状态,无法重加载");
  24. return;
  25. }
  26. location.reload();
  27. }
  28.  
  29. (function() {
  30. if (navigator.userAgent.includes("Chrome") && performance.getEntries()[0].responseStatus != 200) return;
  31. // 设置背景
  32. let back = GM_getValue("background", "https://cdn.luogu.com.cn/images/bg/fe/Day_And_Night_1.jpg");
  33. GM_registerMenuCommand("设置背景URL", () => {
  34. back = window.prompt("请输入背景URL", back);
  35. GM_setValue("background", back);
  36. reloader();
  37. });
  38. let col = GM_getValue("col", "#b93e3e");
  39. const tes = /^#([0-9a-f]{3,4}|[0-9a-f]{6})$/i;
  40. function getColor(t) {
  41. do {
  42. tmp = window.prompt("请输入颜色的Hexcode\n(比如#b93e3e)\n建议选择背景主色调的反差色", t);
  43. } while (!tes.test(t));
  44. return t;
  45. }
  46. GM_registerMenuCommand("设置文字颜色", () => {
  47. GM_setValue("col", getColor(col));
  48. reloader();
  49. });
  50. let collink = GM_getValue("collink", "#ff4c8c");
  51. GM_registerMenuCommand("设置链接背景颜色", () => {
  52. GM_setValue("collink", getColor(collink));
  53. reloader();
  54. });
  55. // if(window.location.href.match(/\/problem\/description\/[^\/]+$/)) {
  56. // console.log("error!!!");
  57. // GM_addStyle(
  58. // "dd {background-color: rgba(255,255,255,70%) !important;border-radius: 0.25rem !important;}"
  59. // );
  60. // } else
  61. {
  62. GM_addStyle("body {background: url("+back+") no-repeat center top fixed;background-size: 100% 100%;-moz-background-size: 100% 100%;}");
  63. document.body.innerHTML = "<nav style='height: 60px'></nav>" + document.body.innerHTML;
  64. }
  65.  
  66. GM_addStyle(
  67. ".navbar {border-radius:0rem;background-color: rgba(0,0,0,65%) !important;position: fixed;top: 0;left: 0;z-index: 1000;width: 100%;}"+
  68. "scrollbar-width: none"+
  69. "#prob-ads {display: none;}"+
  70. "#img-support {display: none;}"+
  71. ".card, .list-group-item, .btn-secondary, .page-link, .page-item.disabled .page-link, .dropdown-menu {background-color: rgba(255,255,255,65%);}"+
  72. ".modal-content {background-color: rgba(255,255,255,90%);}"+
  73. ".form-control {background-color: rgba(255,255,255,50%);}"+
  74. ".tab-content {background-color: rgba(255,255,255,50%);border: 2px solid #eceeef;border-radius: 0.25rem;padding: 20px;}"+
  75. "a:focus, a:hover {color: "+collink+";text-decoration: underline;}"+
  76. "body {color: "+col+";}"
  77. );
  78.  
  79. document.querySelector("body > div.body-footer").innerHTML += '<p style="color: #3fb98b">Theme powered by vjudge+background (original by <a href="https://github.com/dffxd-suntra/vjudge-plus">vjudge+</a>)</p>';
  80. })();