Ex124OJ

Extend 124OJ!

当前为 2023-09-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Ex124OJ
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.6
  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. /***/ 103:
  181. /***/ ((__unused_webpack_module, exports) => {
  182.  
  183.  
  184. Object.defineProperty(exports, "__esModule", ({ value: true }));
  185. exports.ContestsCard = void 0;
  186. function ContestsCard() {
  187. var content = document.querySelector('div.uoj-content');
  188. if (content && content.children.length > 1) {
  189. var TabList = document.createElement('ul');
  190. content.insertBefore(TabList, content.children[0]);
  191. TabList.setAttribute('class', 'nav nav-tabs');
  192. TabList.setAttribute('role', 'tablist');
  193. var TabContent = document.createElement('div');
  194. content.insertBefore(TabContent, content.children[1]);
  195. TabContent.setAttribute('class', 'tab-content');
  196. TabContent.style.marginBottom = '20px';
  197. TabContent.style.marginTop = '20px';
  198. var counter = 0;
  199. for (var i = 2; i < content.children.length; i++) {
  200. console.log(content.children[i].tagName);
  201. if (content.children[i].tagName.toUpperCase() == 'H4') {
  202. var isActive = !counter;
  203. var title = document.createElement('li');
  204. TabList.appendChild(title);
  205. title.setAttribute('class', 'nav-item');
  206. var titleText = content.children[i].textContent;
  207. if (titleText) {
  208. titleText = titleText.charAt(0).toUpperCase() + titleText.slice(1);
  209. title.innerHTML = "<a class=\"nav-link".concat(isActive ? ' active' : '', "\" href=\"#card").concat(counter, "\" role=\"tab\" data-toggle=\"tab\" aria-selected=\"true\">").concat(titleText, "</a>");
  210. }
  211. var card = document.createElement('div');
  212. TabContent.appendChild(card);
  213. card.setAttribute('class', "tab-pane".concat(isActive ? ' active' : ''));
  214. card.setAttribute('id', "card".concat(counter));
  215. content.removeChild(content.children[i]);
  216. counter++;
  217. }
  218. else if (counter) {
  219. TabContent.children[counter - 1].appendChild(content.children[i]);
  220. }
  221. else {
  222. content.removeChild(content.children[i]);
  223. }
  224. i--;
  225. }
  226. }
  227. }
  228. exports.ContestsCard = ContestsCard;
  229.  
  230.  
  231. /***/ }),
  232.  
  233. /***/ 992:
  234. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  235.  
  236.  
  237. Object.defineProperty(exports, "__esModule", ({ value: true }));
  238. exports.DiscussionCard = void 0;
  239. var variables_1 = __webpack_require__(449);
  240. function DiscussionCard() {
  241. var footer = document.querySelector('div.uoj-footer');
  242. if (footer) {
  243. var discrd = document.createElement('div');
  244. discrd.setAttribute('class', 'giscus');
  245. footer.insertBefore(discrd, footer.firstChild);
  246. GM_addElement('script', {
  247. 'src': 'https://giscus.app/client.js',
  248. 'data-repo': 'Sukwants/Ex124OJ-discussions',
  249. 'data-repo-id': 'R_kgDOImiZLA',
  250. 'data-category': 'Ideas',
  251. 'data-category-id': 'DIC_kwDOImiZLM4CTCIj',
  252. 'data-mapping': 'pathname',
  253. 'data-strict': '0',
  254. 'data-reactions-enabled': '1',
  255. 'data-emit-metadata': '0',
  256. 'data-input-position': 'top',
  257. 'data-theme': 'light',
  258. 'data-lang': 'zh-CN',
  259. 'data-loading': 'lazy',
  260. 'crossorigin': 'anonymous',
  261. 'async': ''
  262. });
  263. GM_addStyle(".giscus {\n display: ".concat((variables_1.Academic == true ? 'none' : 'unset'), ";\n}\n.giscus-frame {\n margin-top: 20px;\n}"));
  264. }
  265. }
  266. exports.DiscussionCard = DiscussionCard;
  267.  
  268.  
  269. /***/ }),
  270.  
  271. /***/ 400:
  272. /***/ ((__unused_webpack_module, exports) => {
  273.  
  274.  
  275. Object.defineProperty(exports, "__esModule", ({ value: true }));
  276. exports.FontAwesome = void 0;
  277. function FontAwesome() {
  278. GM_addElement('link', {
  279. href: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.1/css/fontawesome.css',
  280. rel: 'stylesheet'
  281. });
  282. GM_addElement('link', {
  283. href: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.1/css/brands.css',
  284. rel: 'stylesheet'
  285. });
  286. GM_addElement('link', {
  287. href: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.1/css/solid.css',
  288. rel: 'stylesheet'
  289. });
  290. }
  291. exports.FontAwesome = FontAwesome;
  292.  
  293.  
  294. /***/ }),
  295.  
  296. /***/ 18:
  297. /***/ ((__unused_webpack_module, exports) => {
  298.  
  299.  
  300. Object.defineProperty(exports, "__esModule", ({ value: true }));
  301. exports.changeGravatarURL = void 0;
  302. function changeGravatarURL() {
  303. var GravatarURLRegExp = /\/\/cn.gravatar.com\/avatar\/(.*)/;
  304. var Gravatars = document.querySelectorAll('img');
  305. for (var i in Gravatars) {
  306. if (Gravatars[i] && Gravatars[i].nodeType
  307. && GravatarURLRegExp.test(Gravatars[i].getAttribute('src'))
  308. && Gravatars[i].getAttribute('alt').toLowerCase().includes('avatar')) {
  309. Gravatars[i].setAttribute('src', '//cravatar.cn/avatar/' + Gravatars[i].getAttribute('src').match(GravatarURLRegExp)[1]);
  310. }
  311. }
  312. }
  313. exports.changeGravatarURL = changeGravatarURL;
  314.  
  315.  
  316. /***/ }),
  317.  
  318. /***/ 819:
  319. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  320.  
  321.  
  322. Object.defineProperty(exports, "__esModule", ({ value: true }));
  323. exports.NameBadge = exports.NameColor = void 0;
  324. var variables_1 = __webpack_require__(449);
  325. function NameColor() {
  326. function setNameColor() {
  327. var _a;
  328. var Names = document.querySelectorAll('.uoj-username, .uoj-honor');
  329. var NeedsRepeat = false;
  330. for (var i in Names) {
  331. if (Names[i].innerHTML && variables_1.NameColorList[Names[i].innerHTML]) {
  332. Names[i].style.color = variables_1.NameColorList[Names[i].innerHTML][0];
  333. var resN = '';
  334. for (var char = 1; char < variables_1.NameColorList[Names[i].innerHTML].length; ++char) {
  335. resN = resN + "<font style=\"color:".concat(variables_1.NameColorList[Names[i].innerHTML][char], "\">").concat(Names[i].innerHTML.substring(char - 1, char), "</font>");
  336. }
  337. Names[i].innerHTML = resN + Names[i].innerHTML.substring(variables_1.NameColorList[Names[i].innerHTML].length - 1);
  338. if (((_a = Names[i].parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute('class')) === 'legendLabel') {
  339. NeedsRepeat = true;
  340. }
  341. }
  342. }
  343. return NeedsRepeat;
  344. }
  345. if (setNameColor())
  346. setInterval(setNameColor, 200);
  347. }
  348. exports.NameColor = NameColor;
  349. function NameBadge() {
  350. function setNameBadge() {
  351. var _a;
  352. var ccfbadgecode = function (color) { return "<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(color, ";--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>"); };
  353. var tagbadgecode = function (color, text) { return "<span style=\"background-color:".concat(color, ";padding:0.2em 0.6em;border-radius:.2em;color:#fff;font-size:0.7em;font-weight:bold;display:inline-block\">").concat(text, "</span>"); };
  354. var Names = document.querySelectorAll('.uoj-username, .uoj-honor');
  355. for (var i in Names) {
  356. var name_1 = Names[i].textContent;
  357. if (!name_1 || ((_a = Names[i].parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute('class')) == 'legendLabel')
  358. continue;
  359. if (variables_1.CCFBadgeList[name_1]) {
  360. for (var j in variables_1.CCFBadgeList[name_1]) {
  361. // console.log(name, Names[i].textContent, CCFBadgeList[name][j]);
  362. Names[i].innerHTML += " ".concat(ccfbadgecode(variables_1.CCFBadgeList[name_1][j]));
  363. }
  364. }
  365. if (variables_1.TagBadgeList[name_1]) {
  366. for (var j in variables_1.TagBadgeList[name_1]) {
  367. // console.log(Names[i].textContent, TagBadgeList[name][j]);
  368. Names[i].innerHTML += " ".concat(tagbadgecode(variables_1.TagBadgeList[name_1][j].color, variables_1.TagBadgeList[name_1][j].text));
  369. }
  370. }
  371. }
  372. }
  373. setNameBadge();
  374. }
  375. exports.NameBadge = NameBadge;
  376.  
  377.  
  378. /***/ }),
  379.  
  380. /***/ 823:
  381. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  382.  
  383.  
  384. Object.defineProperty(exports, "__esModule", ({ value: true }));
  385. exports.downloadData = void 0;
  386. var utils_1 = __webpack_require__(593);
  387. function downloadData() {
  388. GM_addStyle(".partly-hidden {\n transition: opacity 125ms;\n}\n.partly-hidden:not(:hover) {\n opacity: 0;\n}");
  389. var tabcontent = document.querySelector('div.tab-content');
  390. if (tabcontent) {
  391. var navbar = document.createElement('div');
  392. tabcontent.before(navbar);
  393. navbar.setAttribute('style', 'border-bottom: 1px solid #dee2e6;');
  394. var statisticsButton = document.querySelector('div.uoj-content > a[role=button]');
  395. if (statisticsButton)
  396. navbar.appendChild(statisticsButton);
  397. var DownloadTag = document.createElement('a');
  398. navbar.appendChild(DownloadTag);
  399. DownloadTag.setAttribute('role', 'button');
  400. DownloadTag.setAttribute('class', 'btn btn-primary float-right partly-hidden');
  401. DownloadTag.setAttribute('href', '/download.php?type=problem&id=' + (0, utils_1.isProblem)()[1]);
  402. DownloadTag.setAttribute('target', '_blank');
  403. DownloadTag.innerHTML = '<span class="glyphicon glyphicon-download-alt"></span> 下载数据';
  404. var navtabs = document.querySelector('div.uoj-content > ul[role=tablist]');
  405. if (navtabs) {
  406. navbar.appendChild(navtabs);
  407. navtabs.setAttribute('style', 'border-bottom: none');
  408. var TJTag = document.createElement('li');
  409. navtabs.insertBefore(TJTag, null);
  410. TJTag.setAttribute('class', 'nav-item partly-hidden');
  411. var TJInnerTag = document.createElement('a');
  412. TJTag.appendChild(TJInnerTag);
  413. TJInnerTag.setAttribute('role', 'tab');
  414. TJInnerTag.setAttribute('class', 'nav-link');
  415. TJInnerTag.setAttribute('href', '/download.php?type=tj&id=' + (0, utils_1.isProblem)()[1]);
  416. TJInnerTag.innerHTML = '<span class="glyphicon glyphicon-book"></span> 题解';
  417. }
  418. }
  419. }
  420. exports.downloadData = downloadData;
  421.  
  422.  
  423. /***/ }),
  424.  
  425. /***/ 310:
  426. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  427.  
  428.  
  429. Object.defineProperty(exports, "__esModule", ({ value: true }));
  430. exports.Settings = void 0;
  431. var variables_1 = __webpack_require__(449);
  432. function Settings() {
  433. 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}");
  434. var HomepageEntrance = document.createElement('li');
  435. var NavBarTablist = document.querySelector('div[role=main] > div > ul[role=tablist]');
  436. NavBarTablist.insertBefore(HomepageEntrance, NavBarTablist.firstChild);
  437. HomepageEntrance.setAttribute('class', 'nav-item');
  438. 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>';
  439. HomepageEntrance.onclick = function () {
  440. document.body.setAttribute('class', 'settings-popup-active');
  441. };
  442. var SettingsOverlay = document.createElement('div');
  443. document.body.insertBefore(SettingsOverlay, document.body.firstChild);
  444. SettingsOverlay.setAttribute('class', 'settings-overlay');
  445. var SettingsPopup = document.createElement('div');
  446. SettingsOverlay.appendChild(SettingsPopup);
  447. SettingsPopup.setAttribute('class', 'settings-popup');
  448. var SettingsTitlebar = document.createElement('div');
  449. SettingsPopup.appendChild(SettingsTitlebar);
  450. SettingsTitlebar.setAttribute('class', 'row settings-titlebar');
  451. 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>';
  452. var SettingsCloseButton = document.createElement('span');
  453. SettingsPopup.appendChild(SettingsCloseButton);
  454. SettingsCloseButton.setAttribute('style', 'position: fixed;right: 20px;top:20px;cursor: pointer');
  455. SettingsCloseButton.setAttribute('onclick', 'document.body.setAttribute(\'class\', \'\');');
  456. SettingsCloseButton.innerHTML = '<h4><i class="fa fa-xmark"></i></h4>';
  457. var background = document.createElement('div');
  458. SettingsPopup.appendChild(background);
  459. background.setAttribute('class', 'row');
  460. var backgroundImageLabel = document.createElement('strong');
  461. background.appendChild(backgroundImageLabel);
  462. backgroundImageLabel.setAttribute('style', 'font-size: 1.25em');
  463. backgroundImageLabel.innerHTML = '背景图片&emsp;&emsp;&emsp;&emsp;';
  464. var backgroundImageInput = document.createElement('input');
  465. background.appendChild(backgroundImageInput);
  466. backgroundImageInput.setAttribute('style', 'flex-grow: 1; height: 2em; width: initial');
  467. backgroundImageInput.setAttribute('class', 'form-control');
  468. var siteIcon = document.createElement('div');
  469. SettingsPopup.appendChild(siteIcon);
  470. siteIcon.setAttribute('class', 'row');
  471. var siteIconImageLabel = document.createElement('strong');
  472. siteIcon.appendChild(siteIconImageLabel);
  473. siteIconImageLabel.setAttribute('style', 'font-size: 1.25em');
  474. siteIconImageLabel.innerHTML = '网站图标&emsp;&emsp;&emsp;&emsp;';
  475. var siteIconImageInput = document.createElement('input');
  476. siteIcon.appendChild(siteIconImageInput);
  477. siteIconImageInput.setAttribute('style', 'flex-grow: 1; height: 2em; width: initial');
  478. siteIconImageInput.setAttribute('class', 'form-control');
  479. var siteIconSmall = document.createElement('div');
  480. SettingsPopup.appendChild(siteIconSmall);
  481. siteIconSmall.setAttribute('class', 'row');
  482. var siteIconSmallImageLabel = document.createElement('strong');
  483. siteIconSmall.appendChild(siteIconSmallImageLabel);
  484. siteIconSmallImageLabel.setAttribute('style', 'font-size: 1.25em');
  485. siteIconSmallImageLabel.innerHTML = '网站图标(小)&emsp;';
  486. var siteIconSmallImageInput = document.createElement('input');
  487. siteIconSmall.appendChild(siteIconSmallImageInput);
  488. siteIconSmallImageInput.setAttribute('style', 'flex-grow: 1; height: 2em; width: initial');
  489. siteIconSmallImageInput.setAttribute('class', 'form-control');
  490. var academic = document.createElement('div');
  491. SettingsPopup.appendChild(academic);
  492. academic.setAttribute('class', 'row');
  493. academic.setAttribute('style', 'line-height: 2.5em;vertical-align: middle');
  494. var academicLabel = document.createElement('strong');
  495. academic.appendChild(academicLabel);
  496. academicLabel.setAttribute('style', 'font-size: 1.25em');
  497. academicLabel.innerHTML = '学术模式&emsp;&emsp;&emsp;&emsp;';
  498. var academicOff = document.createElement('div');
  499. academic.appendChild(academicOff);
  500. academicOff.innerHTML = '<input type="radio" id="AcademicOff"> 关闭&emsp;';
  501. var academicOn = document.createElement('div');
  502. academic.appendChild(academicOn);
  503. academicOn.innerHTML = '<input type="radio" id="AcademicOn"> 开启&emsp;';
  504. document.getElementById('AcademicOff').onclick = function () {
  505. document.getElementById('AcademicOn').checked = false;
  506. };
  507. document.getElementById('AcademicOn').onclick = function () {
  508. document.getElementById('AcademicOff').checked = false;
  509. };
  510. backgroundImageInput.value = variables_1.BackgroundImage;
  511. siteIconImageInput.value = variables_1.SiteIconImage;
  512. siteIconSmallImageInput.value = variables_1.SiteIconSmallImage;
  513. document.getElementById('AcademicOff').checked = !variables_1.Academic;
  514. document.getElementById('AcademicOn').checked = variables_1.Academic;
  515. var FooterRow = document.createElement('div');
  516. FooterRow.setAttribute('class', 'settings-footerbar');
  517. SettingsPopup.appendChild(FooterRow);
  518. var Ok = document.createElement('button');
  519. FooterRow.appendChild(Ok);
  520. Ok.setAttribute('class', 'btn btn-search btn-outline-primary float-right');
  521. Ok.innerHTML = '保存';
  522. Ok.onclick = function () {
  523. GM_setValue('BackgroundImage', backgroundImageInput.value);
  524. GM_setValue('SiteIconImage', siteIconImageInput.value);
  525. GM_setValue('SiteIconSmallImage', siteIconSmallImageInput.value);
  526. GM_setValue('Academic', document.getElementById('AcademicOn').checked);
  527. location.reload();
  528. };
  529. var Clear = document.createElement('button');
  530. FooterRow.appendChild(Clear);
  531. Clear.setAttribute('class', 'btn btn-search btn-outline-primary float-right');
  532. Clear.innerHTML = '恢复默认';
  533. Clear.onclick = function () {
  534. var values = GM_listValues();
  535. for (var value in values) {
  536. GM_deleteValue(values[value]);
  537. }
  538. location.reload();
  539. };
  540. }
  541. exports.Settings = Settings;
  542.  
  543.  
  544. /***/ }),
  545.  
  546. /***/ 978:
  547. /***/ ((__unused_webpack_module, exports) => {
  548.  
  549.  
  550. Object.defineProperty(exports, "__esModule", ({ value: true }));
  551. exports.SubmissionCard = void 0;
  552. function SubmissionCard() {
  553. var _a;
  554. GM_addStyle("div.tab-content > div.tab-pane.card {\n border-top: none;\n border-top-right-radius: 0;\n border-top-left-radius: 0;\n}");
  555. var content = document.querySelector('div.uoj-content');
  556. if (content && content.children.length > 1) {
  557. var TabList = document.createElement('ul');
  558. content.insertBefore(TabList, content.children[1]);
  559. TabList.setAttribute('class', 'nav nav-tabs');
  560. TabList.setAttribute('role', 'tablist');
  561. var TabContent = document.createElement('div');
  562. content.insertBefore(TabContent, content.children[2]);
  563. TabContent.setAttribute('class', 'tab-content');
  564. TabContent.style.marginBottom = '20px';
  565. var counter = 0;
  566. for (var i = 3; i < content.children.length; i++, counter++) {
  567. var classlist = content.children[i].getAttribute('class');
  568. if (classlist && classlist.includes('card')) {
  569. var isActive = !counter;
  570. var title = document.createElement('li');
  571. TabList.appendChild(title);
  572. title.setAttribute('class', 'nav-item');
  573. var titleText = (_a = content.children[i].querySelector('h4.card-title')) === null || _a === void 0 ? void 0 : _a.textContent;
  574. if (titleText) {
  575. titleText = titleText.charAt(0).toUpperCase() + titleText.slice(1);
  576. title.innerHTML = "<a class=\"nav-link".concat(isActive ? ' active' : '', "\" href=\"#card").concat(counter, "\" role=\"tab\" data-toggle=\"tab\" aria-selected=\"true\">").concat(titleText, "</a>");
  577. }
  578. var card = document.createElement('div');
  579. TabContent.appendChild(card);
  580. card.setAttribute('class', "tab-pane card".concat(isActive ? ' active' : ''));
  581. card.setAttribute('id', "card".concat(counter));
  582. var card_body = content.children[i].querySelector('div.card-body');
  583. if (card_body)
  584. card.appendChild(card_body);
  585. var card_footer = content.children[i].querySelector('div.card-footer');
  586. if (card_footer)
  587. card.appendChild(card_footer);
  588. content.removeChild(content.children[i]);
  589. i--;
  590. }
  591. }
  592. }
  593. }
  594. exports.SubmissionCard = SubmissionCard;
  595.  
  596.  
  597. /***/ }),
  598.  
  599. /***/ 900:
  600. /***/ ((__unused_webpack_module, exports) => {
  601.  
  602.  
  603. Object.defineProperty(exports, "__esModule", ({ value: true }));
  604. exports.TableStyle = void 0;
  605. function TableStyle() {
  606. var Tables = document.getElementsByTagName('table');
  607. for (var table in Tables) {
  608. if (Tables[table].nodeType) {
  609. var parentNode = Tables[table].parentNode;
  610. var parentClass = parentNode.getAttribute('class');
  611. var classList = Tables[table].classList;
  612. if (parentClass !== 'legend' && classList.length === 0) {
  613. Tables[table].classList.add('table', 'table-bordered');
  614. }
  615. }
  616. }
  617. var ths = document.getElementsByTagName('th');
  618. for (var th in ths) {
  619. if (ths[th].nodeType && ths[th].getAttribute('align')) {
  620. ths[th].setAttribute('style', 'text-align:' + ths[th].getAttribute('align'));
  621. }
  622. }
  623. }
  624. exports.TableStyle = TableStyle;
  625.  
  626.  
  627. /***/ }),
  628.  
  629. /***/ 720:
  630. /***/ ((__unused_webpack_module, exports) => {
  631.  
  632.  
  633. Object.defineProperty(exports, "__esModule", ({ value: true }));
  634. exports.RandomProblem = void 0;
  635. function RandomProblem() {
  636. var SearchBox = document.getElementById('form-search-problem');
  637. if (SearchBox) {
  638. var RandomButton = document.createElement('div');
  639. RandomButton.setAttribute('class', 'input-group-append');
  640. RandomButton.innerHTML = '<button class="btn btn-search btn-outline-primary" style="height: calc(1.5em + 0.75rem + 2px);" onclick="randomProblem();">随机跳题</button>';
  641. var RandomScript = document.createElement('script');
  642. RandomScript.innerHTML =
  643. "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}";
  644. SearchBox.after(RandomButton);
  645. RandomButton.after(RandomScript);
  646. }
  647. }
  648. exports.RandomProblem = RandomProblem;
  649.  
  650.  
  651. /***/ }),
  652.  
  653. /***/ 593:
  654. /***/ ((__unused_webpack_module, exports) => {
  655.  
  656.  
  657. Object.defineProperty(exports, "__esModule", ({ value: true }));
  658. exports.isBlog = exports.isUserProfile = exports.isProblem = exports.isContests = exports.isSubmission = exports.isHomepage = void 0;
  659. var HomepageRegExp = /^http:\/\/124.221.194.184(\/)?(\?.*)?$/;
  660. function isHomepage() {
  661. return window.location.href.match(HomepageRegExp);
  662. }
  663. exports.isHomepage = isHomepage;
  664. var submissionRegExp = /^http:\/\/124.221.194.184\/submission\/\d+(\?.*)?$/;
  665. function isSubmission() {
  666. return window.location.href.match(submissionRegExp);
  667. }
  668. exports.isSubmission = isSubmission;
  669. var ContestsRegExp = /^http:\/\/124.221.194.184\/contests(\/)?(\?.*)?$/;
  670. function isContests() {
  671. return window.location.href.match(ContestsRegExp);
  672. }
  673. exports.isContests = isContests;
  674. var ProblemRegExp = /^http:\/\/124.221.194.184.*\/problem\/(\d+)(\?.*)?$/;
  675. function isProblem() {
  676. return window.location.href.match(ProblemRegExp);
  677. }
  678. exports.isProblem = isProblem;
  679. var UserProfileRegExp = /^http:\/\/124.221.194.184\/user\/profile\/.+(\?.*)?$/;
  680. function isUserProfile() {
  681. return window.location.href.match(UserProfileRegExp);
  682. }
  683. exports.isUserProfile = isUserProfile;
  684. var BlogRegExp = /^http:\/\/124.221.194.184\/blog\/.+(\?.*)?$/;
  685. function isBlog() {
  686. return window.location.href.match(BlogRegExp);
  687. }
  688. exports.isBlog = isBlog;
  689.  
  690.  
  691. /***/ }),
  692.  
  693. /***/ 449:
  694. /***/ ((__unused_webpack_module, exports) => {
  695.  
  696.  
  697. Object.defineProperty(exports, "__esModule", ({ value: true }));
  698. exports.getVariables = exports.TagBadgeList = exports.CCFBadgeList = exports.NameColorList = exports.Academic = exports.SiteIconSmallImage = exports.SiteIconImage = exports.BackgroundImage = exports.version = void 0;
  699. exports.version = "1.0.6";
  700. function getRandomColorCode() {
  701. var letters = '0123456789ABCDEF';
  702. var colorCode = '#';
  703. for (var i = 0; i < 6; i++) {
  704. colorCode += letters[Math.floor(Math.random() * 16)];
  705. }
  706. return colorCode;
  707. }
  708. function getVariables(callback) {
  709. exports.BackgroundImage = GM_getValue('BackgroundImage', '');
  710. exports.SiteIconImage = GM_getValue('SiteIconImage', '');
  711. exports.SiteIconSmallImage = GM_getValue('SiteIconSmallImage', '');
  712. exports.Academic = GM_getValue('Academic', false);
  713. GM_xmlhttpRequest({
  714. method: "GET",
  715. url: "https://ex124oj.pond.ink/public/variables.json",
  716. revalidate: true,
  717. onload: function (data) {
  718. var variables = JSON.parse(data.response);
  719. var randomcolor = getRandomColorCode();
  720. exports.NameColorList = variables.NameColorList;
  721. for (var i in exports.NameColorList) {
  722. for (var j = 0; j < exports.NameColorList[i].length; j++) {
  723. if (exports.NameColorList[i][j] == 'rand') {
  724. exports.NameColorList[i][j] = randomcolor;
  725. }
  726. }
  727. }
  728. exports.CCFBadgeList = variables.CCFBadgeList;
  729. for (var i in exports.CCFBadgeList) {
  730. for (var j = 0; j < exports.CCFBadgeList[i].length; j++) {
  731. if (exports.CCFBadgeList[i][j] == 'rand') {
  732. exports.CCFBadgeList[i][j] = randomcolor;
  733. }
  734. }
  735. }
  736. exports.TagBadgeList = variables.TagBadgeList;
  737. for (var i in exports.TagBadgeList) {
  738. for (var j = 0; j < exports.TagBadgeList[i].length; j++) {
  739. if (exports.TagBadgeList[i][j].color == 'rand') {
  740. exports.TagBadgeList[i][j].color = randomcolor;
  741. }
  742. }
  743. }
  744. callback();
  745. }
  746. });
  747. }
  748. exports.getVariables = getVariables;
  749.  
  750.  
  751. /***/ })
  752.  
  753. /******/ });
  754. /************************************************************************/
  755. /******/ // The module cache
  756. /******/ var __webpack_module_cache__ = {};
  757. /******/
  758. /******/ // The require function
  759. /******/ function __webpack_require__(moduleId) {
  760. /******/ // Check if module is in cache
  761. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  762. /******/ if (cachedModule !== undefined) {
  763. /******/ return cachedModule.exports;
  764. /******/ }
  765. /******/ // Create a new module (and put it into the cache)
  766. /******/ var module = __webpack_module_cache__[moduleId] = {
  767. /******/ // no module.id needed
  768. /******/ // no module.loaded needed
  769. /******/ exports: {}
  770. /******/ };
  771. /******/
  772. /******/ // Execute the module function
  773. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  774. /******/
  775. /******/ // Return the exports of the module
  776. /******/ return module.exports;
  777. /******/ }
  778. /******/
  779. /************************************************************************/
  780. var __webpack_exports__ = {};
  781. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  782. (() => {
  783. var exports = __webpack_exports__;
  784. var __webpack_unused_export__;
  785.  
  786. /// <reference path="index.d.ts" />
  787. __webpack_unused_export__ = ({ value: true });
  788. var utils_1 = __webpack_require__(593);
  789. var variables_1 = __webpack_require__(449);
  790. var settings_1 = __webpack_require__(310);
  791. var name_1 = __webpack_require__(819);
  792. var fontawesome_1 = __webpack_require__(400);
  793. var appearance_1 = __webpack_require__(690);
  794. var discussion_1 = __webpack_require__(992);
  795. var contest_1 = __webpack_require__(103);
  796. var code_1 = __webpack_require__(480);
  797. var table_1 = __webpack_require__(900);
  798. var toolbar_1 = __webpack_require__(720);
  799. var announcement_1 = __webpack_require__(579);
  800. var submission_1 = __webpack_require__(978);
  801. var problem_1 = __webpack_require__(823);
  802. var gravatar_1 = __webpack_require__(18);
  803. (function () {
  804. 'use strict';
  805. (0, variables_1.getVariables)(function () {
  806. (0, settings_1.Settings)();
  807. (0, name_1.NameColor)();
  808. (0, name_1.NameBadge)();
  809. });
  810. (0, fontawesome_1.FontAwesome)();
  811. (0, appearance_1.Background)();
  812. (0, appearance_1.changeIcon)();
  813. (0, discussion_1.DiscussionCard)();
  814. (0, code_1.CodeBlock)();
  815. (0, table_1.TableStyle)();
  816. (0, toolbar_1.RandomProblem)();
  817. if ((0, utils_1.isHomepage)())
  818. (0, announcement_1.exAnnouncements)();
  819. if ((0, utils_1.isSubmission)())
  820. (0, submission_1.SubmissionCard)();
  821. if ((0, utils_1.isContests)())
  822. (0, contest_1.ContestsCard)();
  823. if ((0, utils_1.isProblem)())
  824. (0, problem_1.downloadData)();
  825. if ((0, utils_1.isUserProfile)() || (0, utils_1.isBlog)())
  826. (0, gravatar_1.changeGravatarURL)();
  827. })();
  828.  
  829. })();
  830.  
  831. /******/ })()
  832. ;