Ex124OJ

Extend 124OJ!

当前为 2023-08-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Ex124OJ
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.2
  5. // @description Extend 124OJ!
  6. // @author Sukwants
  7. // @license MIT
  8. // @match http://124.221.194.184/*
  9. // @icon https://ex124oj.pond.ink/images/icon.png
  10. // @grant GM_addElement
  11. // @grant GM_addStyle
  12. // @grant GM_setClipboard
  13. // @grant GM_getValue
  14. // @grant GM_setValue
  15. // @grant GM_deleteValue
  16. // @grant GM_listValues
  17. // @grant GM_xmlhttpRequest
  18. // @connect ex124oj.pond.ink
  19. // ==/UserScript==
  20.  
  21.  
  22. /******/ (() => { // webpackBootstrap
  23. /******/ "use strict";
  24. /******/ var __webpack_modules__ = ({
  25.  
  26. /***/ 579:
  27. /***/ ((__unused_webpack_module, exports) => {
  28.  
  29.  
  30. Object.defineProperty(exports, "__esModule", ({ value: true }));
  31. exports.exAnnouncements = void 0;
  32. function exAnnouncements() {
  33. var PostsExp = /<body[\s\S]*?>([\s\S]*?)<\/body>/;
  34. var WrittenByExp = /^by (.*)$/;
  35. var DateTimeExp = /^(.*?) .*$/;
  36. if (document.getElementsByClassName('uoj-content')[0].children[0].children[0].children[0]) {
  37. GM_xmlhttpRequest({
  38. method: "GET",
  39. url: "https://ex124oj.pond.ink/categories/Announcements/",
  40. revalidate: true,
  41. onload: function (data) {
  42. var Announcements = document.querySelector('div.uoj-content > div.card.card-default > div.card-body > div.row > div:first-child > table');
  43. if (Announcements) {
  44. Announcements.querySelector('thead > tr').innerHTML = '<th style="width:30%">公告</th><th style="width:10%"></th><th style="width:10%"></th><th style="width:30%">Ex 公告</th><th style="width:10%"></th><th style="width:10%"></th>';
  45. var trs = Announcements.querySelectorAll('tbody > tr');
  46. for (var tr = 0; tr < trs.length - 1; ++tr) {
  47. if (trs[tr].innerHTML) {
  48. trs[tr].innerHTML = (trs[tr].children.length > 2 ? trs[tr].innerHTML : '<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>') + '<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>';
  49. if (WrittenByExp.test(trs[tr].children[1] && trs[tr].children[1].innerHTML)) {
  50. trs[tr].children[1].innerHTML = trs[tr].children[1].innerHTML.match(WrittenByExp)[1];
  51. }
  52. if (DateTimeExp.test(trs[tr].children[2] && trs[tr].children[2].innerHTML)) {
  53. trs[tr].children[2].innerHTML = '<small>' + trs[tr].children[2].textContent.match(DateTimeExp)[1] + '</small>';
  54. }
  55. }
  56. }
  57. trs[trs.length - 1].innerHTML = '<td class="text-right" colspan="3"><a href="/announcements">所有公告……</a></td><td class="text-right" colspan="3"><a href="https://ex124oj.pond.ink/categories/Announcements/">所有公告……</a></td>';
  58. var PostsPage = (new DOMParser()).parseFromString(data.response, 'text/html');
  59. var Posts = PostsPage.querySelectorAll('article');
  60. for (var i = 0; i < Posts.length && i < 5; ++i) {
  61. var title = Posts[i].querySelector('a.post-title-link');
  62. Announcements.querySelector('tbody').children[i].children[3].innerHTML = "<a href=\"https://ex124oj.pond.ink".concat(title.getAttribute('href'), "\">").concat(title.innerText, "</a>");
  63. Announcements.querySelector('tbody').children[i].children[4].innerHTML = '<a class="uoj-username" href="https://ex124oj.pond.ink/" style="color:rgb(40,173,202)">Ex124OJ</a>';
  64. var date = Posts[i].querySelector('time');
  65. Announcements.querySelector('tbody').children[i].children[5].innerHTML = '<small>' + date.getAttribute('content') + '</small>';
  66. }
  67. }
  68. }
  69. });
  70. }
  71. }
  72. exports.exAnnouncements = exAnnouncements;
  73.  
  74.  
  75. /***/ }),
  76.  
  77. /***/ 690:
  78. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  79.  
  80.  
  81. Object.defineProperty(exports, "__esModule", ({ value: true }));
  82. exports.changeIcon = exports.Background = void 0;
  83. var variables_1 = __webpack_require__(449);
  84. function Background() {
  85. if (variables_1.BackgroundImage) {
  86. document.getElementsByClassName('navbar-brand')[0].innerHTML = '<img src="/images/logo_small.png" alt="Logo" class="img-rounded" style="width:39px; height:39px;">';
  87. var container = document.getElementsByClassName('container')[0];
  88. if (container) {
  89. var firstChild = container.children[0];
  90. if (firstChild && firstChild.children.length >= 2) {
  91. var innerHTML = firstChild.children[1].innerHTML;
  92. var matchResult = innerHTML.match(/(.*> ){0,1}(.*)/);
  93. if (matchResult) {
  94. var newInnerHTML = matchResult[2];
  95. firstChild.children[1].innerHTML = newInnerHTML;
  96. }
  97. }
  98. }
  99. GM_addStyle("body {\n background: url(\"' + BackgroundImage + '\");\n background-repeat: no-repeat;\n background-attachment: fixed;\n background-position: 50% 50%;\n background-size: cover;\n}\n.uoj-content {\n background-color: #fff;\n margin: 16px -16px;\n padding: 16px 16px;\n opacity: 0.85;\n border-radius: 8px;\n}\n.navbar {\n margin: 16px -16px;\n padding: 8px 16px;\n opacity: 0.85;\n border-radius: 8px;\n}\n.giscus {\n opacity: 0.85;\n}");
  100. }
  101. }
  102. exports.Background = Background;
  103. function getIcon() {
  104. if (variables_1.SiteIconImage)
  105. return variables_1.SiteIconImage;
  106. else
  107. return '/images/logo.png';
  108. }
  109. function getIconSmall() {
  110. if (variables_1.SiteIconSmallImage)
  111. return variables_1.SiteIconSmallImage;
  112. else
  113. return getIcon();
  114. }
  115. function changeIcon() {
  116. var LogoURLRegExp = /^.*\/images\/logo(_small){0,1}.png$/;
  117. var Links = document.getElementsByTagName('link');
  118. for (var link in Links) {
  119. if (Links[link] && Links[link].nodeType && Links[link].getAttribute('rel') == 'shortcut icon') {
  120. Links[link].setAttribute('href', getIconSmall());
  121. }
  122. }
  123. var Icons = document.getElementsByTagName('img');
  124. for (var icon in Icons) {
  125. if (Icons[icon] instanceof Element && Icons[icon].nodeType === Node.ELEMENT_NODE) {
  126. var srcAttribute = Icons[icon].getAttribute('src');
  127. if (srcAttribute !== null && LogoURLRegExp.test(srcAttribute)) {
  128. if (!Icons[icon].getAttribute('style')) {
  129. Icons[icon].setAttribute('src', getIcon());
  130. Icons[icon].setAttribute('style', 'width:100%;height:auto;object-fit:cover');
  131. }
  132. else {
  133. Icons[icon].setAttribute('src', getIconSmall());
  134. }
  135. }
  136. }
  137. }
  138. }
  139. exports.changeIcon = changeIcon;
  140.  
  141.  
  142. /***/ }),
  143.  
  144. /***/ 480:
  145. /***/ ((__unused_webpack_module, exports) => {
  146.  
  147.  
  148. Object.defineProperty(exports, "__esModule", ({ value: true }));
  149. exports.CodeBlock = void 0;
  150. function CodeBlock() {
  151. GM_addStyle("@import url(https://cdn.jsdelivr.net/npm/firacode@6.2.0/distr/fira_code.css);\ncode {\n font-family: \"Fira Code\";\n}\ncode.sh_cpp>span {\n font-style: normal !important;\n font-weight: 400 !important;\n}\ncode.sh_cpp>span.sh_preproc,\ncode.sh_cpp>span.sh_keyword,\ncode.sh_cpp>span.sh_type {\n color: #8959a8;\n}\ncode.sh_cpp>span.sh_string {\n color: #718c00;\n}\ncode.sh_cpp>span.sh_cbracket {\n color: #4d4d4c;\n}\ncode.sh_cpp>span.sh_symbol {\n color: #3e999f;\n}\ncode.sh_cpp>span.sh_number {\n color: #f5871f;\n}\ncode.sh_cpp>span.sh_function {\n color: #4271ae;\n}\ncode.sh_cpp>span.sh_comment {\n color: #8e908c;\n}\n.copybutton {\n font-size: 1.1em;\n width: 2.2em;\n height: 2.2em;\n padding: 0;\n position: absolute;\n top: 0;\n right: 0;\n background-color: rgb(0,0,0,.1);\n border: 0 solid transparent;\n border-bottom-left-radius: .28571429rem;\n}\n.copybutton:hover {\n background-color: rgb(0,0,0,.2);\n}\n.copybutton:focus {\n outline: none;\n}");
  152. if (!(/^.*\/manage\/statement(\?.*){0,1}$/).test(window.location.href)) {
  153. var CodeBlocks = document.getElementsByTagName('pre');
  154. var _loop_1 = function (cb) {
  155. if (CodeBlocks[cb] && CodeBlocks[cb].nodeType) {
  156. var Content_1 = CodeBlocks[cb].innerText;
  157. CodeBlocks[cb].style.position = 'relative';
  158. var CopyButton_1 = document.createElement('button');
  159. CodeBlocks[cb].insertBefore(CopyButton_1, CodeBlocks[cb].children[0]);
  160. CopyButton_1.setAttribute('class', 'copybutton');
  161. CopyButton_1.setAttribute('id', "copybutton".concat(cb));
  162. CopyButton_1.innerHTML = '<i class="fa-solid fa-copy"></i>';
  163. CopyButton_1.onclick = function () {
  164. GM_setClipboard(Content_1, 'text');
  165. CopyButton_1.innerHTML = '<i class="fa-solid fa-check"></i>';
  166. setTimeout(function () { CopyButton_1.innerHTML = '<i class="fa-solid fa-copy"></i>'; }, 500);
  167. };
  168. }
  169. };
  170. for (var cb in CodeBlocks) {
  171. _loop_1(cb);
  172. }
  173. }
  174. }
  175. exports.CodeBlock = CodeBlock;
  176.  
  177.  
  178. /***/ }),
  179.  
  180. /***/ 992:
  181. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  182.  
  183.  
  184. Object.defineProperty(exports, "__esModule", ({ value: true }));
  185. exports.DiscussionCard = void 0;
  186. var variables_1 = __webpack_require__(449);
  187. function DiscussionCard() {
  188. var footer = document.querySelector('div.uoj-footer');
  189. if (footer) {
  190. var discrd = document.createElement('div');
  191. discrd.setAttribute('class', 'giscus');
  192. footer.insertBefore(discrd, footer.firstChild);
  193. GM_addElement('script', {
  194. 'src': 'https://giscus.app/client.js',
  195. 'data-repo': 'Sukwants/Ex124OJ-discussions',
  196. 'data-repo-id': 'R_kgDOImiZLA',
  197. 'data-category': 'Ideas',
  198. 'data-category-id': 'DIC_kwDOImiZLM4CTCIj',
  199. 'data-mapping': 'pathname',
  200. 'data-strict': '0',
  201. 'data-reactions-enabled': '1',
  202. 'data-emit-metadata': '0',
  203. 'data-input-position': 'top',
  204. 'data-theme': 'preferred_color_scheme',
  205. 'data-lang': 'zh-CN',
  206. 'data-loading': 'lazy',
  207. 'crossorigin': 'anonymous',
  208. 'async': ''
  209. });
  210. GM_addStyle(".giscus {\n display: ".concat((variables_1.Academic == true ? 'none' : 'unset'), ";\n}\n.giscus-frame {\n margin-top: 20px;\n}"));
  211. }
  212. }
  213. exports.DiscussionCard = DiscussionCard;
  214.  
  215.  
  216. /***/ }),
  217.  
  218. /***/ 400:
  219. /***/ ((__unused_webpack_module, exports) => {
  220.  
  221.  
  222. Object.defineProperty(exports, "__esModule", ({ value: true }));
  223. exports.FontAwesome = void 0;
  224. function FontAwesome() {
  225. GM_addElement('link', {
  226. href: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.1/css/fontawesome.css',
  227. rel: 'stylesheet'
  228. });
  229. GM_addElement('link', {
  230. href: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.1/css/brands.css',
  231. rel: 'stylesheet'
  232. });
  233. GM_addElement('link', {
  234. href: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.1/css/solid.css',
  235. rel: 'stylesheet'
  236. });
  237. }
  238. exports.FontAwesome = FontAwesome;
  239.  
  240.  
  241. /***/ }),
  242.  
  243. /***/ 18:
  244. /***/ ((__unused_webpack_module, exports) => {
  245.  
  246.  
  247. Object.defineProperty(exports, "__esModule", ({ value: true }));
  248. exports.changeGravatarURL = void 0;
  249. function changeGravatarURL() {
  250. var GravatarURLRegExp = /\/\/cn.gravatar.com\/avatar\/(.*)/;
  251. var Gravatars = document.querySelectorAll('img');
  252. for (var i in Gravatars) {
  253. if (Gravatars[i] && Gravatars[i].nodeType
  254. && GravatarURLRegExp.test(Gravatars[i].getAttribute('src'))
  255. && Gravatars[i].getAttribute('alt').toLowerCase().includes('avatar')) {
  256. Gravatars[i].setAttribute('src', '//cravatar.cn/avatar/' + Gravatars[i].getAttribute('src').match(GravatarURLRegExp)[1]);
  257. }
  258. }
  259. }
  260. exports.changeGravatarURL = changeGravatarURL;
  261.  
  262.  
  263. /***/ }),
  264.  
  265. /***/ 819:
  266. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  267.  
  268.  
  269. Object.defineProperty(exports, "__esModule", ({ value: true }));
  270. exports.NameBadge = exports.NameColor = void 0;
  271. var variables_1 = __webpack_require__(449);
  272. function NameColor() {
  273. var _a;
  274. var Names = document.getElementsByClassName('uoj-username');
  275. var NeedsRepeat = false;
  276. for (var i in Names) {
  277. if (Names[i].innerHTML && variables_1.NameColorList[Names[i].innerHTML]) {
  278. Names[i].style.color = variables_1.NameColorList[Names[i].innerHTML][0];
  279. var resN = '';
  280. for (var charN = 1; charN < variables_1.NameColorList[Names[i].innerHTML].length; ++charN) {
  281. resN = resN + "<font style=\"color:".concat(variables_1.NameColorList[Names[i].innerHTML][charN], "\">").concat(Names[i].innerHTML.substring(charN - 1, charN), "</font>");
  282. }
  283. Names[i].innerHTML = resN + Names[i].innerHTML.substring(variables_1.NameColorList[Names[i].innerHTML].length - 1);
  284. if (((_a = Names[i].parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute('class')) === 'legendLabel') {
  285. NeedsRepeat = true;
  286. }
  287. }
  288. }
  289. if (NeedsRepeat) {
  290. setInterval(function () {
  291. var _a;
  292. var Names = document.getElementsByClassName('uoj-username');
  293. for (var i in Names) {
  294. if (Names[i].innerHTML && ((_a = Names[i].parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute('class')) === 'legendLabel' && variables_1.NameColorList[Names[i].innerHTML]) {
  295. Names[i].style.color = variables_1.NameColorList[Names[i].innerHTML][0];
  296. var resN = '';
  297. for (var charN = 1; charN < variables_1.NameColorList[Names[i].innerHTML].length; ++charN) {
  298. resN = resN + "<font style=\"color:".concat(variables_1.NameColorList[Names[i].innerHTML][charN], "\">").concat(Names[i].innerHTML.substring(charN - 1, charN), "</font>");
  299. }
  300. Names[i].innerHTML = resN + Names[i].innerHTML.substring(variables_1.NameColorList[Names[i].innerHTML].length - 1);
  301. }
  302. }
  303. }, 200);
  304. }
  305. var Honors = document.getElementsByClassName('uoj-honor');
  306. for (var j in Honors) {
  307. if (Honors[j].innerHTML && variables_1.NameColorList[Honors[j].innerHTML]) {
  308. Honors[j].style.color = variables_1.NameColorList[Honors[j].innerHTML][0];
  309. var resH = '';
  310. for (var charH = 1; charH < variables_1.NameColorList[Honors[j].innerHTML].length; ++charH) {
  311. resH = resH + "<font style=\"color:".concat(variables_1.NameColorList[Honors[j].innerHTML][charH], "\">").concat(Honors[j].innerHTML.substring(charH - 1, charH), "</font>");
  312. }
  313. Honors[j].innerHTML = resH + Honors[j].innerHTML.substring(variables_1.NameColorList[Honors[j].innerHTML].length - 1);
  314. }
  315. }
  316. }
  317. exports.NameColor = NameColor;
  318. function NameBadge() {
  319. var _a, _b;
  320. var Names = document.getElementsByClassName('uoj-username');
  321. for (var i in Names) {
  322. if (!Names[i].innerHTML)
  323. continue;
  324. var name_1 = Names[i].textContent;
  325. if (variables_1.CCFBadgeList[name_1] && ((_a = Names[i].parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute('class')) !== 'legendLabel') {
  326. Names[i].innerHTML = Names[i].innerHTML + " <svg width=\"1em\" height=\"1em\" data-v-303bbf52=\"\" aria-hidden=\"true\" focusable=\"false\" data-prefix=\"fad\" data-icon=\"badge-check\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" style=\"margin-bottom:.25em!important;bottom:10px;--fa-primary-color:#fff;--fa-secondary-color:".concat(variables_1.CCFBadgeList[name_1], ";--fa-secondary-opacity:1;\"><g data-v-303bbf52=\"\" class=\"fa-group\"><path data-v-303bbf52=\"\" fill=\"var(--fa-secondary-color)\" d=\"M512 256a88 88 0 0 0-57.1-82.4A88 88 0 0 0 338.4 57.1a88 88 0 0 0-164.8 0A88 88 0 0 0 57.1 173.6a88 88 0 0 0 0 164.8 88 88 0 0 0 116.5 116.5 88 88 0 0 0 164.8 0 88 88 0 0 0 116.5-116.5A88 88 0 0 0 512 256zm-144.8-44.25l-131 130a11 11 0 0 1-15.55-.06l-75.72-76.33a11 11 0 0 1 .06-15.56L171 224a11 11 0 0 1 15.56.06l42.15 42.49 97.2-96.42a11 11 0 0 1 15.55.06l25.82 26a11 11 0 0 1-.08 15.56z\" class=\"fa-secondary\"></path></g></svg>");
  327. }
  328. if (variables_1.TagBadgeList[name_1] && ((_b = Names[i].parentElement) === null || _b === void 0 ? void 0 : _b.getAttribute('class')) !== 'legendLabel') {
  329. Names[i].innerHTML = Names[i].innerHTML + " <span style=\"background-color:".concat(variables_1.TagBadgeList[name_1][0], ";padding:0.2em 0.6em;border-radius:.2em;color:#fff;font-size:0.7em;font-weight:bold;display:inline-block\">").concat(variables_1.TagBadgeList[name_1][1], "</span>");
  330. }
  331. }
  332. var Honors = document.getElementsByClassName('uoj-honor');
  333. for (var j in Honors) {
  334. if (!Honors[j].innerHTML)
  335. continue;
  336. var honor = Honors[j].textContent;
  337. if (variables_1.CCFBadgeList[honor]) {
  338. Honors[j].innerHTML = Honors[j].innerHTML + " <svg width=\"1em\" height=\"1em\" data-v-303bbf52=\"\" aria-hidden=\"true\" focusable=\"false\" data-prefix=\"fad\" data-icon=\"badge-check\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" style=\"margin-bottom:.25em!important;bottom:10px;--fa-primary-color:#fff;--fa-secondary-color:".concat(variables_1.CCFBadgeList[honor], ";--fa-secondary-opacity:1;\"><g data-v-303bbf52=\"\" class=\"fa-group\"><path data-v-303bbf52=\"\" fill=\"var(--fa-secondary-color)\" d=\"M512 256a88 88 0 0 0-57.1-82.4A88 88 0 0 0 338.4 57.1a88 88 0 0 0-164.8 0A88 88 0 0 0 57.1 173.6a88 88 0 0 0 0 164.8 88 88 0 0 0 116.5 116.5 88 88 0 0 0 164.8 0 88 88 0 0 0 116.5-116.5A88 88 0 0 0 512 256zm-144.8-44.25l-131 130a11 11 0 0 1-15.55-.06l-75.72-76.33a11 11 0 0 1 .06-15.56L171 224a11 11 0 0 1 15.56.06l42.15 42.49 97.2-96.42a11 11 0 0 1 15.55.06l25.82 26a11 11 0 0 1-.08 15.56z\" class=\"fa-secondary\"></path></g></svg>");
  339. }
  340. if (variables_1.TagBadgeList[honor]) {
  341. Honors[j].innerHTML = Honors[j].innerHTML + " <span style=\"background-color:".concat(variables_1.TagBadgeList[honor][0], ";padding:0.2em 0.6em;border-radius:.2em;color:#fff;font-size:0.7em;font-weight:bold;display:inline-block\">").concat(variables_1.TagBadgeList[honor][1], "</span>");
  342. }
  343. }
  344. }
  345. exports.NameBadge = NameBadge;
  346.  
  347.  
  348. /***/ }),
  349.  
  350. /***/ 823:
  351. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  352.  
  353.  
  354. Object.defineProperty(exports, "__esModule", ({ value: true }));
  355. exports.downloadData = void 0;
  356. var utils_1 = __webpack_require__(593);
  357. function downloadData() {
  358. var DownloadTag = document.createElement('a');
  359. document.querySelector('div.uoj-content > a[role=button]').after(DownloadTag);
  360. DownloadTag.setAttribute('role', 'button');
  361. DownloadTag.setAttribute('class', 'btn btn-primary float-right');
  362. DownloadTag.setAttribute('href', '/download.php?type=problem&id=' + (0, utils_1.isProblem)()[1]);
  363. DownloadTag.setAttribute('target', '_blank');
  364. DownloadTag.innerHTML = '<span class="glyphicon glyphicon-download-alt"></span> 下载数据';
  365. var navtabs = document.querySelector('div.uoj-content > ul[role=tablist]');
  366. if (navtabs) {
  367. var TJTag = document.createElement('li');
  368. navtabs.insertBefore(TJTag, null);
  369. TJTag.setAttribute('class', 'nav-item');
  370. var TJInnerTag = document.createElement('a');
  371. TJTag.appendChild(TJInnerTag);
  372. TJInnerTag.setAttribute('role', 'tab');
  373. TJInnerTag.setAttribute('class', 'nav-link');
  374. TJInnerTag.setAttribute('href', '/download.php?type=tj&id=' + (0, utils_1.isProblem)()[1]);
  375. TJInnerTag.innerHTML = '<span class="glyphicon glyphicon-book"></span> 题解';
  376. }
  377. }
  378. exports.downloadData = downloadData;
  379.  
  380.  
  381. /***/ }),
  382.  
  383. /***/ 310:
  384. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  385.  
  386.  
  387. Object.defineProperty(exports, "__esModule", ({ value: true }));
  388. exports.Settings = void 0;
  389. var variables_1 = __webpack_require__(449);
  390. function Settings() {
  391. GM_addStyle(".settings-overlay {\n position: fixed;\n height: 100%;\n width: 100%;\n transition: visibility 0.4s, background 0.4s;\n top: 0;\n left: 0;\n visibility: hidden;\n z-index: 229;\n}\n.settings-popup-active .settings-overlay {\n background: rgb(0,0,0,.3);\n visibility: visible;\n}\n.settings-popup {\n width: 60%;\n position: relative;\n transform: translate(-50%, -50%);\n top: 50%;\n left: 50%;\n visibility: hidden;\n border-radius: .5rem;\n padding: 20px 20px;\n}\n.settings-popup-active .settings-overlay .settings-popup {\n background: #ffffff;\n visibility: visible;\n}\n.settings-popup .row {\n padding: 0 30px 30px;\n}\n.settings-titlebar {\n padding: 10px 20px 30px 20px !important;\n}\n.settings-titlebar h4 {\n position: relative;\n top: 50%;\n left: 0;\n transform: translate(0, -50%);\n}\n.settings-footerbar {\n height: 60px;\n padding: 20px 20px;\n}");
  392. var HomepageEntrance = document.createElement('li');
  393. var NavBarTablist = document.querySelector('div[role=main] > div > ul[role=tablist]');
  394. NavBarTablist.insertBefore(HomepageEntrance, NavBarTablist.firstChild);
  395. HomepageEntrance.setAttribute('class', 'nav-item');
  396. HomepageEntrance.innerHTML = '<span style="padding: 0.5rem 1rem; cursor:pointer"><span style="background-color: #28adca;padding:0.2em 0.6em;border-radius: 1em;color:#fff;font-size: 0.7em;font-weight:bold;display:inline-block;position: relative;top: 50%;transform: translate(0,-50%);">Ex124OJ</span></span>';
  397. HomepageEntrance.onclick = function () {
  398. document.body.setAttribute('class', 'settings-popup-active');
  399. };
  400. var SettingsOverlay = document.createElement('div');
  401. document.body.insertBefore(SettingsOverlay, document.body.firstChild);
  402. SettingsOverlay.setAttribute('class', 'settings-overlay');
  403. var SettingsPopup = document.createElement('div');
  404. SettingsOverlay.appendChild(SettingsPopup);
  405. SettingsPopup.setAttribute('class', 'settings-popup');
  406. var SettingsTitlebar = document.createElement('div');
  407. SettingsPopup.appendChild(SettingsTitlebar);
  408. SettingsTitlebar.setAttribute('class', 'row settings-titlebar');
  409. SettingsTitlebar.innerHTML = '<h3 style="width:100%;height:3.5rem"><img src="https://ex124oj.pond.ink/images/icon.png" style="height:3.5rem;width:3.5rem;margin-right:10px"><span style="vertical-align:middle"> Ex124OJ 控制面板</span> <span style="vertical-align:middle;cursor:pointer;margin:0 10px" onclick="window.open(\'https://ex124oj.pond.ink/\');"><span style="height:1.75rem;line-height:3.5rem;vertical-align:middle;padding:0 .5rem;background-color:#28adca;border-radius:1em;color:#fff;font-size:1.2rem;font-weight:bold">Ex124OJ</span></span><span style="color:#7f7f7f;line-height:3.5rem;vertical-align:middle;font-size:1.2rem">' + variables_1.version + '</span></h3>';
  410. var SettingsCloseButton = document.createElement('span');
  411. SettingsPopup.appendChild(SettingsCloseButton);
  412. SettingsCloseButton.setAttribute('style', 'position: fixed;right: 20px;top:20px;cursor: pointer');
  413. SettingsCloseButton.setAttribute('onclick', 'document.body.setAttribute(\'class\', \'\');');
  414. SettingsCloseButton.innerHTML = '<h4><i class="fa fa-xmark"></i></h4>';
  415. var background = document.createElement('div');
  416. SettingsPopup.appendChild(background);
  417. background.setAttribute('class', 'row');
  418. var backgroundImageLabel = document.createElement('strong');
  419. background.appendChild(backgroundImageLabel);
  420. backgroundImageLabel.setAttribute('style', 'font-size: 1.25em');
  421. backgroundImageLabel.innerHTML = '背景图片&emsp;&emsp;&emsp;&emsp;';
  422. var backgroundImageInput = document.createElement('input');
  423. background.appendChild(backgroundImageInput);
  424. backgroundImageInput.setAttribute('style', 'flex-grow: 1; height: 2em; width: initial');
  425. backgroundImageInput.setAttribute('class', 'form-control');
  426. var siteIcon = document.createElement('div');
  427. SettingsPopup.appendChild(siteIcon);
  428. siteIcon.setAttribute('class', 'row');
  429. var siteIconImageLabel = document.createElement('strong');
  430. siteIcon.appendChild(siteIconImageLabel);
  431. siteIconImageLabel.setAttribute('style', 'font-size: 1.25em');
  432. siteIconImageLabel.innerHTML = '网站图标&emsp;&emsp;&emsp;&emsp;';
  433. var siteIconImageInput = document.createElement('input');
  434. siteIcon.appendChild(siteIconImageInput);
  435. siteIconImageInput.setAttribute('style', 'flex-grow: 1; height: 2em; width: initial');
  436. siteIconImageInput.setAttribute('class', 'form-control');
  437. var siteIconSmall = document.createElement('div');
  438. SettingsPopup.appendChild(siteIconSmall);
  439. siteIconSmall.setAttribute('class', 'row');
  440. var siteIconSmallImageLabel = document.createElement('strong');
  441. siteIconSmall.appendChild(siteIconSmallImageLabel);
  442. siteIconSmallImageLabel.setAttribute('style', 'font-size: 1.25em');
  443. siteIconSmallImageLabel.innerHTML = '网站图标(小)&emsp;';
  444. var siteIconSmallImageInput = document.createElement('input');
  445. siteIconSmall.appendChild(siteIconSmallImageInput);
  446. siteIconSmallImageInput.setAttribute('style', 'flex-grow: 1; height: 2em; width: initial');
  447. siteIconSmallImageInput.setAttribute('class', 'form-control');
  448. var academic = document.createElement('div');
  449. SettingsPopup.appendChild(academic);
  450. academic.setAttribute('class', 'row');
  451. academic.setAttribute('style', 'line-height: 2.5em;vertical-align: middle');
  452. var academicLabel = document.createElement('strong');
  453. academic.appendChild(academicLabel);
  454. academicLabel.setAttribute('style', 'font-size: 1.25em');
  455. academicLabel.innerHTML = '学术模式&emsp;&emsp;&emsp;&emsp;';
  456. var academicOff = document.createElement('div');
  457. academic.appendChild(academicOff);
  458. academicOff.innerHTML = '<input type="radio" id="AcademicOff"> 关闭&emsp;';
  459. var academicOn = document.createElement('div');
  460. academic.appendChild(academicOn);
  461. academicOn.innerHTML = '<input type="radio" id="AcademicOn"> 开启&emsp;';
  462. document.getElementById('AcademicOff').onclick = function () {
  463. document.getElementById('AcademicOn').checked = false;
  464. };
  465. document.getElementById('AcademicOn').onclick = function () {
  466. document.getElementById('AcademicOff').checked = false;
  467. };
  468. backgroundImageInput.value = variables_1.BackgroundImage;
  469. siteIconImageInput.value = variables_1.SiteIconImage;
  470. siteIconSmallImageInput.value = variables_1.SiteIconSmallImage;
  471. document.getElementById('AcademicOff').checked = !variables_1.Academic;
  472. document.getElementById('AcademicOn').checked = variables_1.Academic;
  473. var FooterRow = document.createElement('div');
  474. FooterRow.setAttribute('class', 'settings-footerbar');
  475. SettingsPopup.appendChild(FooterRow);
  476. var Ok = document.createElement('button');
  477. FooterRow.appendChild(Ok);
  478. Ok.setAttribute('class', 'btn btn-search btn-outline-primary float-right');
  479. Ok.innerHTML = '保存';
  480. Ok.onclick = function () {
  481. GM_setValue('BackgroundImage', backgroundImageInput.value);
  482. GM_setValue('SiteIconImage', siteIconImageInput.value);
  483. GM_setValue('SiteIconSmallImage', siteIconSmallImageInput.value);
  484. GM_setValue('Academic', document.getElementById('AcademicOn').checked);
  485. location.reload();
  486. };
  487. var Clear = document.createElement('button');
  488. FooterRow.appendChild(Clear);
  489. Clear.setAttribute('class', 'btn btn-search btn-outline-primary float-right');
  490. Clear.innerHTML = '恢复默认';
  491. Clear.onclick = function () {
  492. var values = GM_listValues();
  493. for (var value in values) {
  494. GM_deleteValue(values[value]);
  495. }
  496. location.reload();
  497. };
  498. }
  499. exports.Settings = Settings;
  500.  
  501.  
  502. /***/ }),
  503.  
  504. /***/ 978:
  505. /***/ ((__unused_webpack_module, exports) => {
  506.  
  507.  
  508. Object.defineProperty(exports, "__esModule", ({ value: true }));
  509. exports.SubmissionCard = void 0;
  510. function SubmissionCard() {
  511. var _a;
  512. var content = document.querySelector('div.uoj-content');
  513. if (content && content.children.length > 1) {
  514. var TabList = document.createElement('ul');
  515. content.insertBefore(TabList, content.children[1]);
  516. TabList.setAttribute('class', 'nav nav-tabs');
  517. TabList.setAttribute('role', 'tablist');
  518. var TabContent = document.createElement('div');
  519. content.insertBefore(TabContent, content.children[2]);
  520. TabContent.setAttribute('class', 'tab-content');
  521. TabContent.style.marginBottom = '20px';
  522. var counter = 0;
  523. for (var i = 3; i < content.children.length; i++, counter++) {
  524. var classlist = content.children[i].getAttribute('class');
  525. if (classlist && classlist.includes('card')) {
  526. var isActive = !counter;
  527. var title = document.createElement('li');
  528. TabList.appendChild(title);
  529. title.setAttribute('class', 'nav-item');
  530. var titleText = (_a = content.children[i].querySelector('h4.card-title')) === null || _a === void 0 ? void 0 : _a.textContent;
  531. if (titleText) {
  532. titleText = titleText.charAt(0).toUpperCase() + titleText.slice(1);
  533. title.innerHTML = "<a class=\"nav-link".concat(isActive ? ' active' : '', "\" href=\"#card").concat(counter, "\" role=\"tab\" data-toggle=\"tab\" aria-selected=\"true\">").concat(titleText, "</a>");
  534. }
  535. var card = document.createElement('div');
  536. TabContent.appendChild(card);
  537. card.setAttribute('class', "tab-pane card".concat(isActive ? ' active' : ''));
  538. card.setAttribute('id', "card".concat(counter));
  539. var card_body = content.children[i].querySelector('div.card-body');
  540. if (card_body)
  541. card.appendChild(card_body);
  542. var card_footer = content.children[i].querySelector('div.card-footer');
  543. if (card_footer)
  544. card.appendChild(card_footer);
  545. content.removeChild(content.children[i]);
  546. i--;
  547. }
  548. }
  549. }
  550. }
  551. exports.SubmissionCard = SubmissionCard;
  552.  
  553.  
  554. /***/ }),
  555.  
  556. /***/ 900:
  557. /***/ ((__unused_webpack_module, exports) => {
  558.  
  559.  
  560. Object.defineProperty(exports, "__esModule", ({ value: true }));
  561. exports.TableStyle = void 0;
  562. function TableStyle() {
  563. var Tables = document.getElementsByTagName('table');
  564. for (var table in Tables) {
  565. if (Tables[table].nodeType) {
  566. var parentNode = Tables[table].parentNode;
  567. var parentClass = parentNode.getAttribute('class');
  568. var classList = Tables[table].classList;
  569. if (parentClass !== 'legend' && classList.length === 0) {
  570. Tables[table].classList.add('table', 'table-bordered');
  571. }
  572. }
  573. }
  574. var ths = document.getElementsByTagName('th');
  575. for (var th in ths) {
  576. if (ths[th].nodeType && ths[th].getAttribute('align')) {
  577. ths[th].setAttribute('style', 'text-align:' + ths[th].getAttribute('align'));
  578. }
  579. }
  580. }
  581. exports.TableStyle = TableStyle;
  582.  
  583.  
  584. /***/ }),
  585.  
  586. /***/ 720:
  587. /***/ ((__unused_webpack_module, exports) => {
  588.  
  589.  
  590. Object.defineProperty(exports, "__esModule", ({ value: true }));
  591. exports.RandomProblem = void 0;
  592. function RandomProblem() {
  593. var SearchBox = document.getElementById('form-search-problem');
  594. if (SearchBox) {
  595. var RandomButton = document.createElement('div');
  596. RandomButton.setAttribute('class', 'input-group-append');
  597. RandomButton.innerHTML = '<button class="btn btn-search btn-outline-primary" style="height: calc(1.5em + 0.75rem + 2px);" onclick="randomProblem();">随机跳题</button>';
  598. var RandomScript = document.createElement('script');
  599. RandomScript.innerHTML =
  600. "function randomProblem() {\n const randomProblemId = Math.ceil(Math.random() * 3000);\n ($.get('/problem/' + randomProblemId, (data, status) => {\n if (status == 'success') {\n window.location.href = '/problem/' + randomProblemId;\n } else {\n randomProblem();\n }\n })).error(() => {\n randomProblem();\n })\n}";
  601. SearchBox.after(RandomButton);
  602. RandomButton.after(RandomScript);
  603. }
  604. }
  605. exports.RandomProblem = RandomProblem;
  606.  
  607.  
  608. /***/ }),
  609.  
  610. /***/ 593:
  611. /***/ ((__unused_webpack_module, exports) => {
  612.  
  613.  
  614. Object.defineProperty(exports, "__esModule", ({ value: true }));
  615. exports.isBlog = exports.isUserProfile = exports.isProblem = exports.isSubmission = exports.isHomepage = void 0;
  616. var HomepageRegExp = /^http:\/\/124.221.194.184(\/)?(\?.*)?$/;
  617. function isHomepage() {
  618. return window.location.href.match(HomepageRegExp);
  619. }
  620. exports.isHomepage = isHomepage;
  621. var submissionRegExp = /^http:\/\/124.221.194.184\/submission\/\d+(\?.*)?$/;
  622. function isSubmission() {
  623. return window.location.href.match(submissionRegExp);
  624. }
  625. exports.isSubmission = isSubmission;
  626. var ProblemRegExp = /^http:\/\/124.221.194.184.*\/problem\/(\d+)(\?.*)?$/;
  627. function isProblem() {
  628. return window.location.href.match(ProblemRegExp);
  629. }
  630. exports.isProblem = isProblem;
  631. var UserProfileRegExp = /^http:\/\/124.221.194.184\/user\/profile\/.+(\?.*)?$/;
  632. function isUserProfile() {
  633. return window.location.href.match(UserProfileRegExp);
  634. }
  635. exports.isUserProfile = isUserProfile;
  636. var BlogRegExp = /^http:\/\/124.221.194.184\/blog\/.+(\?.*)?$/;
  637. function isBlog() {
  638. return window.location.href.match(BlogRegExp);
  639. }
  640. exports.isBlog = isBlog;
  641.  
  642.  
  643. /***/ }),
  644.  
  645. /***/ 449:
  646. /***/ ((__unused_webpack_module, exports) => {
  647.  
  648.  
  649. Object.defineProperty(exports, "__esModule", ({ value: true }));
  650. exports.getVariables = exports.TagBadgeList = exports.CCFBadgeList = exports.NameColorList = exports.Academic = exports.SiteIconSmallImage = exports.SiteIconImage = exports.BackgroundImage = exports.version = void 0;
  651. exports.version = "1.0.2";
  652. function getVariables(callback) {
  653. exports.BackgroundImage = GM_getValue('BackgroundImage', '');
  654. exports.SiteIconImage = GM_getValue('SiteIconImage', '');
  655. exports.SiteIconSmallImage = GM_getValue('SiteIconSmallImage', '');
  656. exports.Academic = GM_getValue('Academic', false);
  657. GM_xmlhttpRequest({
  658. method: "GET",
  659. url: "https://ex124oj.pond.ink/public/variables.json",
  660. revalidate: true,
  661. onload: function (data) {
  662. var variables = JSON.parse(data.response);
  663. exports.NameColorList = variables.NameColorList;
  664. GM_setValue('NameColorList', exports.NameColorList);
  665. exports.CCFBadgeList = variables.CCFBadgeList;
  666. GM_setValue('CCFBadgeList', exports.CCFBadgeList);
  667. exports.TagBadgeList = variables.TagBadgeList;
  668. GM_setValue('TagBadgeList', exports.TagBadgeList);
  669. callback();
  670. }
  671. });
  672. }
  673. exports.getVariables = getVariables;
  674.  
  675.  
  676. /***/ })
  677.  
  678. /******/ });
  679. /************************************************************************/
  680. /******/ // The module cache
  681. /******/ var __webpack_module_cache__ = {};
  682. /******/
  683. /******/ // The require function
  684. /******/ function __webpack_require__(moduleId) {
  685. /******/ // Check if module is in cache
  686. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  687. /******/ if (cachedModule !== undefined) {
  688. /******/ return cachedModule.exports;
  689. /******/ }
  690. /******/ // Create a new module (and put it into the cache)
  691. /******/ var module = __webpack_module_cache__[moduleId] = {
  692. /******/ // no module.id needed
  693. /******/ // no module.loaded needed
  694. /******/ exports: {}
  695. /******/ };
  696. /******/
  697. /******/ // Execute the module function
  698. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  699. /******/
  700. /******/ // Return the exports of the module
  701. /******/ return module.exports;
  702. /******/ }
  703. /******/
  704. /************************************************************************/
  705. var __webpack_exports__ = {};
  706. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  707. (() => {
  708. var exports = __webpack_exports__;
  709. var __webpack_unused_export__;
  710.  
  711. /// <reference path="index.d.ts" />
  712. __webpack_unused_export__ = ({ value: true });
  713. var utils_1 = __webpack_require__(593);
  714. var variables_1 = __webpack_require__(449);
  715. var settings_1 = __webpack_require__(310);
  716. var name_1 = __webpack_require__(819);
  717. var fontawesome_1 = __webpack_require__(400);
  718. var appearance_1 = __webpack_require__(690);
  719. var announcement_1 = __webpack_require__(579);
  720. var toolbar_1 = __webpack_require__(720);
  721. var discussion_1 = __webpack_require__(992);
  722. var code_1 = __webpack_require__(480);
  723. var table_1 = __webpack_require__(900);
  724. var submission_1 = __webpack_require__(978);
  725. var problem_1 = __webpack_require__(823);
  726. var gravatar_1 = __webpack_require__(18);
  727. (function () {
  728. 'use strict';
  729. (0, variables_1.getVariables)(function () {
  730. (0, settings_1.Settings)();
  731. (0, name_1.NameColor)();
  732. (0, name_1.NameBadge)();
  733. });
  734. (0, fontawesome_1.FontAwesome)();
  735. (0, appearance_1.Background)();
  736. (0, appearance_1.changeIcon)();
  737. (0, discussion_1.DiscussionCard)();
  738. (0, code_1.CodeBlock)();
  739. (0, table_1.TableStyle)();
  740. (0, toolbar_1.RandomProblem)();
  741. if ((0, utils_1.isHomepage)())
  742. (0, announcement_1.exAnnouncements)();
  743. if ((0, utils_1.isSubmission)())
  744. (0, submission_1.SubmissionCard)();
  745. if ((0, utils_1.isProblem)())
  746. (0, problem_1.downloadData)();
  747. if ((0, utils_1.isUserProfile)() || (0, utils_1.isBlog)())
  748. (0, gravatar_1.changeGravatarURL)();
  749. })();
  750.  
  751. })();
  752.  
  753. /******/ })()
  754. ;