0x3f-problem-solution

自定义分数区间显示题目 标记题目状态 配合灵茶山艾府题单解题

2024-10-13 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name 0x3f-problem-solution
  3. // @namespace https://greatest.deepsurf.us/zh-CN/scripts/501134-0x3f-problem-solution
  4. // @version 0.0.5.1
  5. // @author wuxin0011
  6. // @description 自定义分数区间显示题目 标记题目状态 配合灵茶山艾府题单解题
  7. // @license MIT
  8. // @icon https://assets.leetcode.cn/aliyun-lc-upload/users/endlesscheng/avatar_1690721039.png
  9. // @source https://github.com/wuxin0011/tampermonkey-script/tree/main/0x3f-leetcode
  10. // @supportURL https://greatest.deepsurf.us/zh-CN/scripts/501134-0x3f-problem-solution/feedback
  11. // @match https://leetcode.cn/circle/discuss/*
  12. // @match https://leetcode.cn/problems/*
  13. // @match https://leetcode.cn/contest/weekly-contest-*/problems/*
  14. // @match https://leetcode.cn/contest/biweekly-contest-*/problems/*
  15. // @require https://unpkg.com/vue@3.4.31/dist/vue.global.prod.js
  16. // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B
  17. // @require https://unpkg.com/element-plus@2.7.6/dist/index.full.js
  18. // @resource elementPlusCss https://unpkg.com/element-plus@2.7.6/dist/index.css
  19. // @grant GM_addStyle
  20. // @grant GM_deleteValue
  21. // @grant GM_getResourceText
  22. // @grant GM_getValue
  23. // @grant GM_registerMenuCommand
  24. // @grant GM_setValue
  25. // ==/UserScript==
  26.  
  27. (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const e=document.createElement("style");e.textContent=t,document.head.append(e)})(" h2[data-v-49e5e62d]{color:#000;margin:10px 0}em[data-v-49e5e62d]{color:red}.m-setting-button[data-v-003e83a0]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-003e83a0]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-003e83a0]{display:flex;justify-content:center;align-items:center}.m-setting-button[data-v-6868725a]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-6868725a]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-6868725a]{display:flex;justify-content:center;align-items:center} ");
  28.  
  29. (function (vue, ElementPlus) {
  30. 'use strict';
  31.  
  32. var _GM_deleteValue = /* @__PURE__ */ (() => typeof GM_deleteValue != "undefined" ? GM_deleteValue : void 0)();
  33. var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
  34. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  35. var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
  36. class Cache {
  37. set(k, v) {
  38. _GM_setValue(k, v);
  39. }
  40. get(k, parse = true, name = String.name) {
  41. try {
  42. let v = _GM_getValue(k);
  43. switch (name) {
  44. case String.name:
  45. if (v == null) {
  46. return "null";
  47. }
  48. return v;
  49. case Object.name:
  50. if (v == null || v == void 0 || typeof v != "object") {
  51. return {};
  52. }
  53. return v;
  54. case Boolean.name:
  55. if (v === null || v == void 0) {
  56. return false;
  57. }
  58. if (v == false || v == "false" || v == "" || v == "null") {
  59. return false;
  60. }
  61. return v;
  62. case Array.name:
  63. if (v === null || v == void 0 || !Array.isArray(v)) {
  64. return [];
  65. }
  66. return v;
  67. default:
  68. return v;
  69. }
  70. } catch (E) {
  71. return null;
  72. }
  73. }
  74. remove(k) {
  75. _GM_deleteValue(k);
  76. }
  77. }
  78. const Cache$1 = new Cache();
  79. const isHttp = (url) => /^https?:\/\/.*$/.test(url);
  80. const isLeetCodeCircleUrl = (url = window.location.href) => url && url.indexOf("https://leetcode.cn/circle") != -1;
  81. const isProblem = (url = window.location.href) => /^https?:\/\/leetcode.cn\/problems\/.*/i.test(url);
  82. const isContest = (url = window.location.href) => url.indexOf("https://leetcode.cn/contest/weekly-contest") != -1 || url.indexOf("https://leetcode.cn/contest/biweekly-contest") != -1;
  83. const sleep = async (time = 500) => new Promise((resolove) => setTimeout(resolove, time));
  84. const isDev = () => false;
  85. const width = 14;
  86. const height = 14;
  87. const problemFinsh = () => `
  88.  
  89. <svg width="${width}px" height="${height}px" status="ac" viewBox="0 0 1024 1024" version="1.1"
  90. xmlns="http://www.w3.org/2000/svg">
  91. <path d="M512 512m-448 0a448 448 0 1 0 896 0 448 448 0 1 0-896 0Z" fill="#4CAF50" />
  92. <path
  93. d="M738.133333 311.466667L448 601.6l-119.466667-119.466667-59.733333 59.733334 179.2 179.2 349.866667-349.866667z"
  94. fill="#CCFF90" />
  95. </svg>
  96.  
  97. `;
  98. const problemsTry = () => `
  99. <svg width="${width}px" height="${height}px" status="notac" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
  100. xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512"
  101. style="enable-background:new 0 0 512 512;" xml:space="preserve">
  102. <path style="fill:#FEDEA1;" d="M256,12.8C121.899,12.8,12.8,121.899,12.8,256S121.899,499.2,256,499.2S499.2,390.101,499.2,256
  103. S390.101,12.8,256,12.8z" />
  104. <g>
  105. <path style="fill:#573A32;" d="M256,115.2c-49.271,0-92.561,25.353-117.726,63.676l18.859,18.859
  106. C177.178,163.806,213.734,140.8,256,140.8c63.625,0,115.2,51.567,115.2,115.2h-38.4l51.2,51.2l51.2-51.2h-38.4
  107. C396.8,178.244,333.764,115.2,256,115.2z" />
  108. <path style="fill:#573A32;" d="M256,0C114.62,0,0,114.62,0,256s114.62,256,256,256s256-114.62,256-256S397.38,0,256,0z M256,486.4
  109. C128.956,486.4,25.6,383.044,25.6,256S128.956,25.6,256,25.6S486.4,128.956,486.4,256S383.044,486.4,256,486.4z" />
  110. <path style="fill:#573A32;" d="M256,371.2c-63.625,0-115.2-51.567-115.2-115.2h38.4L128,204.8L76.8,256h38.4
  111. c0,77.756,63.036,140.8,140.8,140.8c49.272,0,92.561-25.353,117.726-63.676l-18.859-18.859
  112. C334.822,348.194,298.266,371.2,256,371.2z" />
  113. </g>
  114. </svg>
  115.  
  116. `;
  117. const problemsNo = () => install_pos() ? `
  118. <svg width="${width}px" height="${height}px" status="null" viewBox="0 0 24 24" id="meteor-icon-kit__regular-circle" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z" fill="#758CA3"/></svg>
  119. ` : ``;
  120. const createStatus = (status, link) => {
  121. let node;
  122. if (!link) {
  123. return;
  124. }
  125. node = link instanceof HTMLAnchorElement ? link.parentElement : link;
  126. if (node) {
  127. node.status = status;
  128. }
  129. let installSVG = "";
  130. if (status == STATUS["AC"]) {
  131. installSVG = problemFinsh();
  132. } else if (status == STATUS["notac"]) {
  133. installSVG = problemsTry();
  134. } else if (status == STATUS["NO"]) {
  135. installSVG = problemsNo();
  136. } else {
  137. installSVG = "";
  138. }
  139. let svg = node.querySelector("svg");
  140. if (svg) {
  141. if (svg.getAttribute("status") == status || svg.getAttribute("status") == STATUS["AC"]) {
  142. return false;
  143. }
  144. svg.remove();
  145. }
  146. node.innerHTML = install_pos() ? installSVG + node.innerHTML : node.innerHTML + installSVG;
  147. return true;
  148. };
  149. const inf = 4e3;
  150. const mi = 1e3;
  151. const __0X3F_PROBLEM_KEYS__ = {
  152. "__0x3f_problmes_solution__": "__0x3f_problmes_solution__",
  153. // 基本信息
  154. "__0x3f_problmes_urls__": "__0x3f_problmes_urls__",
  155. // 题单key
  156. "__0x3f_problmes_update__": "__0x3f_problmes_update__",
  157. // 是否修改了默认题单key
  158. "__0x3f_problmes_button_is_none__": "__is_none_0x3f_problmes_button__",
  159. // 是否隐藏设置按钮
  160. "__0x3f_problmes_insert_pos__": "__0x3f_problmes_insert_pos__",
  161. // 安装位置
  162. "__0x3f_problmes_status_update__": "__0x3f_problmes_status_update__",
  163. "__0x3f_problmes_plugin_load_ok__": "__0x3f_problmes_plugin_load_ok__",
  164. // 是否使用插件
  165. "__0x3f_problmes_add_cur__": "__0x3f_problmes_add_cur__",
  166. // 添加 url
  167. "__0x3f_problmes_ac_key__": "__local_ok_problem_key__",
  168. // ac key
  169. "__0x3f_problmes_ac_version__": "__0x3f_problmes_ac_version__",
  170. // TODO ac key version
  171. "__0x3f_problmes_all_problems__": "__0x3f_problmes_all_problems__",
  172. // all problems
  173. "__0x3f_problmes_random_problems_key__": "__0x3f_problmes_random_problems_key__",
  174. //随机题目快捷键
  175. "__0x3f_problmes_random_problems__": "__0x3f_problmes_random_problems__"
  176. //随机题目
  177. };
  178. const STATUS = {
  179. "AC": "ac",
  180. "NO": "null",
  181. "notac": "notac"
  182. };
  183. const defaultObj = {
  184. min: mi,
  185. max: inf,
  186. visiableMember: true,
  187. onlyUrls: false,
  188. useDefaultSetting: true,
  189. hiddenAc: false,
  190. showAcConfig: true
  191. };
  192. function install_pos() {
  193. return !Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_insert_pos__"], false, Boolean.name);
  194. }
  195. function isShow(text, min, max) {
  196. if (!text) {
  197. return true;
  198. }
  199. let res = text.match(/\d+/ig);
  200. if (!res) {
  201. return true;
  202. }
  203. if (Array.isArray(res) && res.length < 2) {
  204. return true;
  205. }
  206. let s = 0;
  207. for (let i = res.length - 1; i >= 0; i--) {
  208. s = res[i];
  209. if (s >= mi && s <= inf) {
  210. return s >= min && s <= max;
  211. }
  212. }
  213. return true;
  214. }
  215. let A = void 0;
  216. const linkCssSelector = `#lc-content [class*="CollapsibleMarkdownContent"] [class*="MarkdownContent"] li>a`;
  217. const queryProblem = () => Array.from(document.querySelectorAll(linkCssSelector)).filter((item) => item && item instanceof HTMLAnchorElement && isProblem(item.href));
  218. function loadProblems() {
  219. A = queryProblem();
  220. return A;
  221. }
  222. function handlerProblem(data) {
  223. var _a;
  224. try {
  225. loadProblems();
  226. let { min, max, visiableMember, useDefaultSetting, onlyUrls, hiddenAc } = data;
  227. if (isNaN(min) || isNaN(max)) {
  228. min = mi;
  229. max = inf;
  230. }
  231. if (min < mi) {
  232. min = mi;
  233. }
  234. if (max < min) {
  235. max = inf;
  236. }
  237. min = Number(min);
  238. max = Number(max);
  239. data.min = min;
  240. data.max = max;
  241. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"], data);
  242. for (let i = 0; i < A.length; i++) {
  243. if (!(A[i] instanceof HTMLAnchorElement)) {
  244. continue;
  245. }
  246. let d = (_a = A[i]) == null ? void 0 : _a.parentNode;
  247. if (!d) {
  248. continue;
  249. }
  250. let none = false;
  251. let Nohidden = isShow(d.textContent, min, max);
  252. d.style.display = Nohidden ? "" : "none";
  253. if (!Nohidden) {
  254. continue;
  255. }
  256. if (hiddenAc) {
  257. const svg = d.querySelector("svg");
  258. if (svg && svg.getAttribute("status")) {
  259. d.style.display = svg.getAttribute("status") == STATUS["AC"] ? "none" : "";
  260. }
  261. } else {
  262. d.style.display = "";
  263. }
  264. let c = d.textContent && d.textContent.indexOf("会员") != -1;
  265. if (!c) {
  266. continue;
  267. }
  268. d.style.display = visiableMember ? "" : "none";
  269. }
  270. } catch (e) {
  271. console.log("error", e);
  272. }
  273. }
  274. function computeAcInfo(saveUrls = [], deleteOk = true) {
  275. let infos = [];
  276. let set = /* @__PURE__ */ new Set();
  277. for (let i = 0, u = null; Array.isArray(saveUrls) && i < saveUrls.length; i++) {
  278. try {
  279. u = saveUrls[i];
  280. if (!(u == null ? void 0 : u.link) || !(u == null ? void 0 : u.title) || !(u == null ? void 0 : u.id) || set.has(u.link)) {
  281. continue;
  282. }
  283. if (u["select"] == void 0) u.select = true;
  284. if (u["loading"] == void 0 || u["loading"]) u["loading"] = false;
  285. let s = Object.values(u).join("");
  286. if (s == "null" || !Cache$1.get(u.link) || !getAcCountKey(u.link) || !Cache$1.get(getAcCountKey(u.link))) {
  287. continue;
  288. }
  289. let o = Cache$1.get(getAcCountKey(u.link));
  290. u["ac"] = isNaN(o["ac"]) ? 0 : parseInt(o["ac"]);
  291. u["tot"] = isNaN(o["tot"]) ? 0 : parseInt(o["tot"]);
  292. set.add(u.link);
  293. } catch (e) {
  294. }
  295. infos.push(Object.assign({}, u));
  296. }
  297. if (deleteOk) {
  298. for (let i = 0; i < saveUrls[i]; i++) {
  299. delete saveUrls[i];
  300. }
  301. for (let info of infos) {
  302. saveUrls.push(info);
  303. }
  304. }
  305. return infos;
  306. }
  307. const initUrls = () => {
  308. let saveUrls = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true, Boolean.name) ? Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], true, Array.name) : defaultUrls;
  309. return computeAcInfo(saveUrls);
  310. };
  311. const initObj = () => {
  312. let obj = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"]) ? Object.assign(defaultObj, Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"])) : defaultObj;
  313. if (obj["showAcConfig"] == null || obj["showAcConfig"] == void 0) {
  314. obj.showAcConfig = true;
  315. }
  316. let temp = {};
  317. for (let key of Object.keys(obj)) {
  318. if (!isNaN(key) || defaultObj[`${key}`] == void 0) continue;
  319. temp[`${key}`] = obj[`${key}`];
  320. }
  321. return temp;
  322. };
  323. const support_plugins = () => {
  324. const u = initObj();
  325. if (!u || !u.onlyUrls) return true;
  326. let url = window.location.href;
  327. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  328. try {
  329. url = url.split("view")[0];
  330. } catch (e) {
  331. url = window.location.href;
  332. }
  333. }
  334. const urls = initUrls();
  335. for (let info of urls) {
  336. if (!info || !(info == null ? void 0 : info.link)) {
  337. continue;
  338. }
  339. if (info.link.indexOf(url) != -1) {
  340. return true;
  341. }
  342. }
  343. return false;
  344. };
  345. const defaultUrls = [
  346. { "title": "数学算法(数论/组合/概率期望/博弈/计算几何/随机算法", "link": "https://leetcode.cn/circle/discuss/IYT3ss/", "tot": 0, "ac": 0, "id": 1, "disabled": false, "select": true },
  347. { "title": "常用数据结构(前缀和/差分/栈/队列/堆/字典树/并查集/树状数组/线段树)", "link": "https://leetcode.cn/circle/discuss/mOr1u6/", "tot": 0, "ac": 0, "id": 2, "disabled": false, "select": true },
  348. { "title": "动态规划(入门/背包/状态机/划分/区间/状压/数位/树形/数据结构优化)", "link": "https://leetcode.cn/circle/discuss/tXLS3i/", "tot": 0, "ac": 0, "id": 3, "disabled": false, "select": true },
  349. { "title": "图论算法(DFS/BFS/拓扑排序/最短路/最小生成树/二分图/基环树/欧拉路径)", "link": "https://leetcode.cn/circle/discuss/01LUak/", "tot": 0, "ac": 0, "id": 4, "disabled": false, "select": true },
  350. { "title": "位运算(基础/性质/拆位/试填/恒等式/贪心/脑筋急转弯)", "link": "https://leetcode.cn/circle/discuss/dHn9Vk/", "tot": 0, "ac": 0, "id": 5, "disabled": false, "select": true },
  351. { "title": "网格图(DFS/BFS/综合应用)", "link": "https://leetcode.cn/circle/discuss/YiXPXW/", "tot": 0, "ac": 0, "id": 6, "disabled": false, "select": true },
  352. { "title": "单调栈(矩形面积/贡献法/最小字典序", "link": "https://leetcode.cn/circle/discuss/9oZFK9/", "tot": 0, "ac": 0, "id": 7, "disabled": false, "select": true },
  353. { "title": "二分算法(二分答案/最小化最大值/最大化最小值/第K小", "link": "https://leetcode.cn/circle/discuss/SqopEo/", "tot": 0, "ac": 0, "id": 8, "disabled": true, "select": true },
  354. { "title": "滑动窗口(定长/不定长/多指针", "link": "https://leetcode.cn/circle/discuss/0viNMK/", "tot": 0, "ac": 0, "id": 9, "disabled": false, "select": true },
  355. { "title": "贪心算法(基本贪心策略/反悔/区间/字典序/数学/思维/构造)", "link": "https://leetcode.cn/circle/discuss/g6KTKL/", "tot": 0, "ac": 0, "id": 10, "disabled": false, "select": true },
  356. { "title": "链表、二叉树与一般树(前后指针/快慢指针/DFS/BFS/直径/LCA)", "link": "https://leetcode.cn/circle/discuss/K0n2gO/", "tot": 0, "ac": 0, "id": 11, "disabled": false, "select": true },
  357. { "title": "字符串(KMP/Z函数/Manacher/字符串哈希/AC自动机/后缀数组/子序列自动机)", "link": "https://leetcode.cn/circle/discuss/SJFwQI/", "tot": 0, "ac": 0, "id": 12, "disabled": false, "select": true }
  358. // { 'title': '灵茶题单完成情况', 'link': 'https://leetcode.cn/u/endlesscheng/', 'tot': 0, 'ac': 0, 'id': 0x3f3f3f3f,'disabled':true,'select':false },
  359. ];
  360. function getId(problemUrl) {
  361. if (isContest(problemUrl) || isProblem(problemUrl)) {
  362. try {
  363. return problemUrl.split("problems")[1].split("/")[1];
  364. } catch (e) {
  365. return "";
  366. }
  367. }
  368. return "";
  369. }
  370. function postData(ID) {
  371. return {
  372. "query": "\n query userQuestionStatus($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n status\n }\n}\n ",
  373. "variables": {
  374. "titleSlug": ID
  375. },
  376. "operationName": "userQuestionStatus"
  377. };
  378. }
  379. async function queryStatus(ID = "", cache = {}, cur = void 0, watch2 = false) {
  380. var _a, _b, _c;
  381. if (!ID) {
  382. return;
  383. }
  384. if (cache[ID] == void 0 || cache[ID] != STATUS["AC"]) {
  385. const response = await getProblemAcInfo(ID);
  386. if ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.question) {
  387. const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status;
  388. if (cache[ID] == void 0 || cache[ID] != status) {
  389. cache[ID] = status == null ? "null" : status;
  390. if (watch2) {
  391. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], cache);
  392. window.localStorage.setItem(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_status_update__"], JSON.stringify({
  393. "id": ID,
  394. "status": cache[ID]
  395. }));
  396. }
  397. createStatus(cache[ID], cur);
  398. }
  399. } else {
  400. console.log("query result is undefined");
  401. }
  402. }
  403. }
  404. async function addProcess(reload = true, doms = void 0, asyncAc = false) {
  405. var _a;
  406. let problems_doms = Array.isArray(doms) ? doms : loadProblems();
  407. const cache = getLocalProblemStatus();
  408. for (let i = 0; i < problems_doms.length; i++) {
  409. let cur = problems_doms[i].parentElement;
  410. if (!(cur instanceof HTMLElement)) {
  411. continue;
  412. }
  413. const ID = getId((_a = problems_doms[i]) == null ? void 0 : _a.href);
  414. if (!ID) {
  415. continue;
  416. }
  417. if (install_pos()) {
  418. cur.style.listStyleType = "none";
  419. }
  420. if (!cache[ID] || cache[ID] != STATUS["AC"] && asyncAc) {
  421. await sleep(200);
  422. await queryStatus(ID, cache, cur, false);
  423. } else {
  424. let status = cache[ID];
  425. createStatus(status, cur);
  426. }
  427. }
  428. getProcess();
  429. if (reload) {
  430. let cnt = 10;
  431. let timeId = setInterval(() => {
  432. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], cache);
  433. getProcess();
  434. cnt--;
  435. if (cnt == 0) {
  436. window.clearInterval(timeId);
  437. }
  438. }, 3e3);
  439. }
  440. }
  441. const submitProblems = (url = window.location.href, timeout = 500) => {
  442. const ID = getId(url);
  443. if (!ID) {
  444. return;
  445. }
  446. setTimeout(() => {
  447. const cache = getLocalProblemStatus();
  448. queryStatus(ID, cache, void 0, true);
  449. }, timeout);
  450. };
  451. const watchLinkStatusUpdate = (e) => {
  452. var _a;
  453. if (e.key != __0X3F_PROBLEM_KEYS__["__0x3f_problmes_status_update__"]) {
  454. return;
  455. }
  456. let { id, status } = JSON.parse(e.newValue);
  457. if (!id || !status) {
  458. return;
  459. }
  460. let thisLink = `https://leetcode.cn/problems/${id}`;
  461. let link = document.querySelector(`${linkCssSelector}[href^="https://leetcode.cn/problems/${id}"]`);
  462. if (!link || !(link == null ? void 0 : link.parentElement)) {
  463. let doms = loadProblems();
  464. for (let i = 0; i < doms.length; i++) {
  465. if (!doms[i] || !((_a = doms[i]) == null ? void 0 : _a.parentElement)) {
  466. continue;
  467. }
  468. if (doms[i].href.indexOf(thisLink) != -1) {
  469. link = doms[i];
  470. break;
  471. }
  472. }
  473. }
  474. createStatus(status, link);
  475. };
  476. function getAcCountKey(k) {
  477. if (!k) return "";
  478. return `0x3f_ac_key_${k}`;
  479. }
  480. function deleteAllACCountKeys() {
  481. let urls = initUrls();
  482. let keys = [];
  483. for (let urlInfo of urls) {
  484. let key = getAcCountKey(urlInfo.link);
  485. Cache$1.remove(key);
  486. keys.push(key);
  487. }
  488. Cache$1.remove(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"]);
  489. return keys;
  490. }
  491. function getProcess() {
  492. loadProblems();
  493. const cache = getLocalProblemStatus();
  494. let cnt = 0;
  495. for (let i = 0; i < A.length; i++) {
  496. let ID = getId(A[i].href);
  497. if (ID && cache[ID] == STATUS["AC"]) {
  498. cnt++;
  499. }
  500. }
  501. let url = window.location.href;
  502. if (A.length > 0 && getAcCountKey(url)) {
  503. Cache$1.set(getAcCountKey(url), { "tot": A.length, "ac": cnt });
  504. }
  505. return [cnt, A.length];
  506. }
  507. function getLocalProblemStatus() {
  508. return Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], true, Object.name);
  509. }
  510. function getRandomInfo(array) {
  511. if (!Array.isArray(array)) return void 0;
  512. return array[Math.floor(Math.random() * array.length)];
  513. }
  514. async function randomProblem() {
  515. let allProbmems;
  516. if (!Array.isArray(allProbmems) || allProbmems.length == 0) {
  517. let response = await getProblemsJSON();
  518. if (Array.isArray(response)) {
  519. allProbmems = [...response];
  520. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_all_problems__"], [...response]);
  521. }
  522. } else {
  523. allProbmems = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_all_problems__"], true, Array.name);
  524. }
  525. if (!Array.isArray(allProbmems)) {
  526. ElementPlus.ElMessage({
  527. type: "error",
  528. message: "随机题目失败获取不到任何信息 !请如果出现这种情况,请前往 https://github.com/wuxin0011/tampermonkey-script/issues 反馈",
  529. duration: 6e3
  530. });
  531. return;
  532. }
  533. let config = initObj();
  534. let urlsData = initUrls();
  535. let set = /* @__PURE__ */ new Set();
  536. for (let info of urlsData) {
  537. if (info.link && info.select) {
  538. set.add(info.link);
  539. }
  540. }
  541. let infos = [];
  542. let acMap = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], true, Object.name);
  543. let count = 0;
  544. next:
  545. for (let info of allProbmems) {
  546. if (!(info == null ? void 0 : info.problemUrl) || !set.has(info == null ? void 0 : info.problemUrl) || !Array.isArray(info.problems) || info.problems.length == 0) {
  547. continue;
  548. }
  549. for (let i = 0; Array.isArray(info.problems) && i < info.problems.length; i++) {
  550. try {
  551. let { title, url, member, score, titleSlug } = info.problems[i];
  552. if (!url || !title) continue;
  553. if (isDev()) ;
  554. if (!(config == null ? void 0 : config.showAcConfig) && acMap[titleSlug] == "ac") {
  555. continue;
  556. }
  557. if (!(config == null ? void 0 : config.visiableMember) && member) {
  558. continue;
  559. }
  560. if (score != 0 && (score < (config == null ? void 0 : config.min) || score > (config == null ? void 0 : config.max))) {
  561. continue;
  562. }
  563. infos.push({ title, url, member, score, titleSlug, "status": acMap[titleSlug] });
  564. } catch (e) {
  565. console.log("error", e);
  566. }
  567. if (count >= 100) {
  568. break next;
  569. }
  570. count += 1;
  571. }
  572. }
  573. let data = getRandomInfo(infos);
  574. ElementPlus.ElMessage({
  575. dangerouslyUseHTMLString: !!(data && (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title)),
  576. type: (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title) ? "success" : "error",
  577. message: (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title) ? `<div>随机题目☕:&nbsp;<a href="${data.url}" target="_blank" style="color:#5d99f2;">${data.title}</a> ${(data == null ? void 0 : data.score) && (data == null ? void 0 : data.score) > 0 ? `&nbsp;分值${data.score}` : ""}</div>` : `没有符合条件的题目,请重新配置条件!`,
  578. duration: 6e3
  579. });
  580. }
  581. async function GetHubJSONInfo(url) {
  582. return fetch(url, {
  583. method: "get",
  584. mode: "cors"
  585. }).then((res) => res.json());
  586. }
  587. async function getProblemsJSON() {
  588. return GetHubJSONInfo("https://raw.githubusercontent.com/wuxin0011/tampermonkey-script/main/0x3f-leetcode/0x3f.json");
  589. }
  590. async function PostLeetCodeApi(data) {
  591. return fetch("https://leetcode.cn/graphql/", {
  592. method: "POST",
  593. credentials: "include",
  594. headers: {
  595. "Content-Type": "application/json"
  596. },
  597. body: JSON.stringify(data)
  598. }).then((res) => res.json());
  599. }
  600. async function getProblemAcInfo(titleSlug) {
  601. return PostLeetCodeApi(postData(titleSlug));
  602. }
  603. const _export_sfc = (sfc, props) => {
  604. const target = sfc.__vccOpts || sfc;
  605. for (const [key, val] of props) {
  606. target[key] = val;
  607. }
  608. return target;
  609. };
  610. const _sfc_main$1 = {};
  611. const _hoisted_1$1 = /* @__PURE__ */ vue.createStaticVNode('<h2 style="color:red !important;" data-v-49e5e62d> 0. 同步功能使用前请确保为登录状态 </h2><h2 data-v-49e5e62d> 1. 为什么部分题单出现统计数量为 <em data-v-49e5e62d> 0 </em> 情况 ? </h2><p data-v-49e5e62d>防止一次性访问题单太多,对服务器产生压力,所以采用单个题单访问然后保存状态 , 这样避免访问量问题</p><p data-v-49e5e62d>默认情况下会缓存访问的题单情况,对于没有访问的题单,可以手动在对应题单中同步</p><h2 data-v-49e5e62d> 2.题单有时候会出现不同步 </h2><p data-v-49e5e62d>这个没啥问题,题目状态根据用户提交题目情况会实时更新,只会在提交访问一次</p><h2 data-v-49e5e62d> 3. 如何使用随机题目? </h2><p data-v-49e5e62d>这个可以根据自己喜好来配置,配置好之后,可以使用 <em data-v-49e5e62d> ctrl + alt + j </em> 触发 </p><h2 data-v-49e5e62d> 4.反馈 </h2>', 9);
  612. function _sfc_render(_ctx, _cache) {
  613. const _component_el_link = vue.resolveComponent("el-link");
  614. return vue.openBlock(), vue.createElementBlock("div", null, [
  615. _hoisted_1$1,
  616. vue.createElementVNode("p", null, [
  617. vue.createTextVNode("你可以"),
  618. vue.createVNode(_component_el_link, {
  619. underline: false,
  620. href: "https://greatest.deepsurf.us/zh-CN/scripts/501134-0x3f-problem-solution/feedback",
  621. type: "primary",
  622. target: "_blank"
  623. }, {
  624. default: vue.withCtx(() => [
  625. vue.createTextVNode("点击")
  626. ]),
  627. _: 1
  628. }),
  629. vue.createTextVNode("这里反馈 ,或者访问 github 提一个 "),
  630. vue.createVNode(_component_el_link, {
  631. target: "_blank",
  632. underline: false,
  633. href: "https://github.com/wuxin0011/tampermonkey-script/issues",
  634. type: "primary"
  635. }, {
  636. default: vue.withCtx(() => [
  637. vue.createTextVNode("issues")
  638. ]),
  639. _: 1
  640. })
  641. ])
  642. ]);
  643. }
  644. const Q1 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-49e5e62d"]]);
  645. function Message(title = "确认操作", callback = () => {
  646. }, canlcelCallback = () => {
  647. }) {
  648. ElementPlus.ElMessageBox.confirm(
  649. `${title} ?`,
  650. "警告",
  651. {
  652. confirmButtonText: "确认",
  653. cancelButtonText: "取消",
  654. type: "warning"
  655. }
  656. ).then(() => {
  657. callback();
  658. }).catch(() => {
  659. ElementPlus.ElMessage({
  660. type: "info",
  661. message: "已取消"
  662. });
  663. canlcelCallback();
  664. });
  665. }
  666. const _hoisted_1 = { class: "dialog-footer" };
  667. const _hoisted_2 = { class: "processs-flex" };
  668. const _hoisted_3 = { style: { "text-align": "center", "color": "#121212" } };
  669. const TARGET_URL = "https://leetcode.cn/u/endlesscheng/";
  670. const formLabelWidth = "44px";
  671. const _sfc_main = {
  672. __name: "App",
  673. setup(__props) {
  674. const sortType = vue.ref(0);
  675. const tableButtonSize = vue.ref("default");
  676. let tableData = vue.reactive(initUrls());
  677. const keywords = vue.ref("");
  678. const dialogTableVisible = vue.ref(false);
  679. const showAddLocalButton = vue.computed(() => isLeetCodeCircleUrl());
  680. let urlsData = vue.computed(() => {
  681. let map = /* @__PURE__ */ new Map();
  682. let infos = tableData.filter((info2) => {
  683. if ((info2 == null ? void 0 : info2.title) && (info2 == null ? void 0 : info2.link) && !map.has(info2.link)) {
  684. map.set(info2.link, info2);
  685. return info2 && (info2.title && info2.title.indexOf(keywords.value) != -1 || info2.link && info2.link.indexOf(keywords.value) != -1);
  686. } else {
  687. return false;
  688. }
  689. });
  690. let tot = 0, ac = 0;
  691. for (let i = 0, c = info.length; i < infos.length; i++) {
  692. let info2 = infos[i];
  693. if (info2["ac"] && info2["tot"]) {
  694. tot += info2["tot"];
  695. ac += info2["ac"];
  696. }
  697. if (!info2["id"]) {
  698. info2["id"] = c + 1;
  699. c++;
  700. }
  701. }
  702. let type = sortType.value;
  703. if (type == 0) {
  704. infos.sort((info1, info2) => info2.id - info1.id);
  705. } else if (type == 1) {
  706. infos.sort((info1, info2) => info2.tot - info1.tot);
  707. } else if (type == 2) {
  708. infos.sort((info1, info2) => info2.ac - info1.ac);
  709. } else if (type == 3) {
  710. infos.sort((info1, info2) => computeProcess(info2.ac, info2.tot) - computeProcess(info1.ac, info1.tot));
  711. }
  712. infos.unshift({ "title": "灵茶题单完成情况", "link": TARGET_URL, "tot": tot, "ac": ac, "id": 67108863 });
  713. return infos;
  714. });
  715. const rowIsDisabled = vue.computed(() => (info2) => asyncButtonLoad.value || info2 && info2.link == TARGET_URL);
  716. const isDisabbled = vue.computed(() => !!tableData.find((v) => (v == null ? void 0 : v.link) && (v == null ? void 0 : v.link.indexOf(window.location.href)) != -1));
  717. const dialogFormVisible = vue.ref(false);
  718. const computeProcess = (ac = 0, tot = 0) => {
  719. if (isNaN(ac) || isNaN(tot) || tot === 0) return 0;
  720. let p = 0;
  721. if (tot == ac) {
  722. return 100;
  723. }
  724. const s = String(ac / tot);
  725. try {
  726. let x1 = s.split(".")[1] || "";
  727. x1 = x1.padEnd(3, "0").substring(0, 3);
  728. p = Math.min(100, Number(x1) / 10);
  729. } catch (e) {
  730. console.log("calc error", e.message, s == void 0, ac, tot);
  731. p = (ac / tot).toFixed(3) * 100;
  732. }
  733. return isNaN(p) ? 0 : p;
  734. };
  735. const processColors = [
  736. { color: "#f56c6c", percentage: 20 },
  737. { color: "#1989fa", percentage: 40 },
  738. { color: "#e6a23c", percentage: 60 },
  739. { color: "#6f7ad3", percentage: 80 },
  740. { color: "#67c23a", percentage: 100 }
  741. ];
  742. const fromData = vue.reactive(initObj());
  743. vue.watch(fromData, () => {
  744. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  745. });
  746. const info = vue.reactive({
  747. title: "",
  748. link: "",
  749. status: "add"
  750. });
  751. const addlocal = () => {
  752. if (!isDisabbled) {
  753. return;
  754. }
  755. let [cur, tot] = getProcess();
  756. tableData.unshift({ title: document.title, link: window.location.href, "ac": cur, "tot": tot, "id": tableData.length + 10 });
  757. };
  758. const updateIndex = vue.ref(-1);
  759. const handlerProblems = (status, updateInfo = { title: "", link: "", id: 0 }, index = -1) => {
  760. dialogFormVisible.value = true;
  761. info.status = status;
  762. updateIndex.value = updateInfo.id;
  763. Object.assign(info, updateInfo);
  764. };
  765. const handlerMessage = (u, title, link) => {
  766. const a = u ? "添加" : "修改";
  767. const error = !(!!title && isHttp(link));
  768. if (error) {
  769. ElementPlus.ElMessage.error(`${a} 失败 请保证标题或者链接有效 `);
  770. } else {
  771. ElementPlus.ElMessage.success(`${a} 成功 `);
  772. }
  773. return !error;
  774. };
  775. const addOrUpdate = () => {
  776. if (!handlerMessage(info.status == "add", info.title, info.link)) {
  777. return;
  778. }
  779. if (info.status == "add") {
  780. tableData.unshift({ title: info.title, link: info.link, "ac": 0, "tot": 0, "id": tableData.length + 10 });
  781. } else {
  782. let id = updateIndex.value;
  783. for (let i = 0; i < tableData.length; i++) {
  784. if (tableData[i] && tableData[i].id && tableData[i]["id"] == id) {
  785. tableData[i]["title"] = info.title;
  786. tableData[i]["link"] = info.link;
  787. break;
  788. }
  789. }
  790. }
  791. dialogFormVisible.value = false;
  792. };
  793. const deleteProblems = (id) => {
  794. for (let i = 0; i < tableData.length; i++) {
  795. if (tableData[i] && tableData[i].id && tableData[i]["id"] == id) {
  796. delete tableData[i];
  797. break;
  798. }
  799. }
  800. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  801. };
  802. const handlerDefault = () => {
  803. Message("确认使用默认题单,将会重置题单", () => {
  804. for (let i = 0; i < tableData.length; i++) {
  805. delete tableData[i];
  806. }
  807. let infos = computeAcInfo(defaultUrls);
  808. for (let item of infos) {
  809. tableData.unshift(item);
  810. }
  811. ElementPlus.ElMessage({
  812. type: "success",
  813. message: "重置成功"
  814. });
  815. });
  816. };
  817. window.addEventListener("beforeunload", () => {
  818. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData).filter((u) => u != null && u != void 0));
  819. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true);
  820. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"], false);
  821. });
  822. vue.onMounted(async () => {
  823. if (support_plugins()) {
  824. let times = 30;
  825. let loadTimeId = setInterval(() => {
  826. let a = queryProblem();
  827. times--;
  828. if (Array.isArray(a) && a.length > 0) {
  829. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  830. addProcess();
  831. window.clearInterval(loadTimeId);
  832. }
  833. if (times == 0) {
  834. window.clearInterval(loadTimeId);
  835. }
  836. }, 200);
  837. }
  838. window.addEventListener("storage", (e) => {
  839. watchLinkStatusUpdate(e);
  840. });
  841. });
  842. _GM_registerMenuCommand(`题单配置信息🛠`, () => {
  843. dialogTableVisible.value = !dialogTableVisible.value;
  844. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  845. const selectHandlerChange = (row) => {
  846. let infos = [];
  847. for (let i = 0; i < urlsData.value.length; i++) {
  848. if (urlsData.value[i]["link"] == TARGET_URL) continue;
  849. infos.push(vue.toRaw(Object.assign({}, urlsData.value[i])));
  850. }
  851. for (let i = 0; i < tableData.length; i++) {
  852. if (row.id == tableData[i].id) {
  853. tableData[i].select = row.select;
  854. break;
  855. }
  856. }
  857. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], infos);
  858. };
  859. const asyncButtonLoad = vue.ref(false);
  860. const asyncButtonLoadBreak = vue.ref(false);
  861. const showProcess = vue.ref(false);
  862. const allProblemNum = vue.ref(0);
  863. const asyncProblemNum = vue.ref(0);
  864. const asyncVisableDialog = vue.ref(false);
  865. const showProblemsProcessInfo = vue.reactive({
  866. title: "",
  867. link: "",
  868. cnt: "",
  869. ac: "",
  870. id: "",
  871. select: true
  872. });
  873. const showProblemsInfo = (info2 = {}) => {
  874. asyncVisableDialog.value = !asyncVisableDialog.value;
  875. Object.assign(showProblemsProcessInfo, info2);
  876. };
  877. const loadProcess = vue.computed(() => computeProcess(asyncProblemNum.value, allProblemNum.value));
  878. const asyncProblemStatus = async (row = {}) => {
  879. if (!(row == null ? void 0 : row.link)) return;
  880. let callback = async () => {
  881. var _a, _b, _c, _d, _e;
  882. let rowData = void 0;
  883. let asyncAll = (row == null ? void 0 : row.link) == TARGET_URL;
  884. let cache = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], true, Object.name);
  885. let map = /* @__PURE__ */ new Map();
  886. try {
  887. for (let info2 of tableData) {
  888. if ((info2 == null ? void 0 : info2.link) && (info2 == null ? void 0 : info2.title) && (info2 == null ? void 0 : info2.id)) {
  889. if (rowData == void 0 && (info2 == null ? void 0 : info2.id) == row.id) {
  890. rowData = info2;
  891. }
  892. if (!map.has(info2.link)) {
  893. map.set(info2.link, info2);
  894. }
  895. }
  896. }
  897. if (rowData) {
  898. rowData.loading = true;
  899. }
  900. asyncButtonLoad.value = true;
  901. asyncButtonLoadBreak.value = false;
  902. allProblemNum.value = 0;
  903. asyncProblemNum.value = 0;
  904. showProcess.value = true;
  905. await sleep(500);
  906. let jsonInfo = await getProblemsJSON();
  907. if (!Array.isArray(jsonInfo)) {
  908. jsonInfo = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_all_problems__"], true, Array.name);
  909. } else {
  910. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_all_problems__"], jsonInfo);
  911. }
  912. let datas = [];
  913. for (let i = 0; Array.isArray(jsonInfo) && i < jsonInfo.length; i++) {
  914. let key = `${(_a = jsonInfo[i]) == null ? void 0 : _a.problemUrl}`;
  915. let origin = map.get(key);
  916. if (!origin) {
  917. continue;
  918. }
  919. if (asyncAll) {
  920. for (let p of jsonInfo[i].problems) {
  921. datas.push(Object.assign({ "origin": jsonInfo[i].problemUrl }, p));
  922. }
  923. origin.tot = Math.max(jsonInfo[i].problems.length, (origin == null ? void 0 : origin.tot) ?? 0);
  924. origin.ac = 0;
  925. } else if (jsonInfo[i].problemUrl == row.link) {
  926. for (let p of jsonInfo[i].problems) {
  927. datas.push(Object.assign({ "origin": jsonInfo[i].problemUrl }, p));
  928. }
  929. origin.tot = Math.max(jsonInfo[i].problems.length, (origin == null ? void 0 : origin.tot) ?? 0);
  930. origin.ac = 0;
  931. break;
  932. }
  933. }
  934. if (Array.isArray(datas) && datas.length > 0) {
  935. allProblemNum.value = datas.length;
  936. asyncProblemNum.value = 0;
  937. let pre = 0;
  938. for (let i = 0; i < datas.length; i++) {
  939. let info2 = datas[i];
  940. try {
  941. if (asyncButtonLoadBreak.value) {
  942. break;
  943. }
  944. await sleep(200);
  945. let ID = info2.titleSlug;
  946. let key = `${info2.origin}`;
  947. let origin = map.get(key);
  948. if (cache[ID] != "ac") {
  949. let response = await getProblemAcInfo(ID);
  950. const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status;
  951. cache[ID] = status == null ? "null" : status;
  952. }
  953. if (origin) {
  954. if (cache[ID] == "ac") {
  955. origin.ac = origin.ac + 1;
  956. }
  957. }
  958. if (isDev()) ;
  959. asyncProblemNum.value += 1;
  960. if (loadProcess.value < pre && isDev()) {
  961. console.warn("calc result is error");
  962. }
  963. pre = loadProcess.value;
  964. } catch (e) {
  965. if (isDev()) ;
  966. }
  967. if (i % 100 == 0) {
  968. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], Object.assign({}, cache));
  969. }
  970. }
  971. }
  972. } catch (e) {
  973. console.log("error", e);
  974. } finally {
  975. if (rowData) {
  976. rowData.loading = false;
  977. }
  978. asyncButtonLoad.value = false;
  979. for (let i = 0; i < tableData.length; i++) {
  980. if (getAcCountKey((_d = tableData[i]) == null ? void 0 : _d.link)) {
  981. Cache$1.set(getAcCountKey(tableData[i].link), { "tot": tableData[i].tot, "ac": tableData[i].ac });
  982. }
  983. if ((_e = tableData[i]) == null ? void 0 : _e.loading) {
  984. tableData[i].loading = false;
  985. }
  986. }
  987. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  988. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], Object.assign({}, cache));
  989. await sleep(500);
  990. ElementPlus.ElMessage({
  991. type: allProblemNum.value == asyncProblemNum.value ? "success" : asyncButtonLoadBreak.value ? "error" : "warning",
  992. message: allProblemNum.value == asyncProblemNum.value ? `同步完成🥰` : asyncButtonLoadBreak.value ? `同步中断 ${loadProcess.value}% ` : `同步率 ${loadProcess.value}% `,
  993. duration: 3e3
  994. });
  995. await sleep(6e3);
  996. allProblemNum.value = 0;
  997. asyncProblemNum.value = 0;
  998. showProcess.value = false;
  999. asyncButtonLoadBreak.value = false;
  1000. }
  1001. };
  1002. if (row.link == TARGET_URL) {
  1003. Message("该操作将同步所有题单,耗时可能较长 确认操作?", callback);
  1004. } else {
  1005. callback();
  1006. }
  1007. };
  1008. const q1 = vue.ref(false);
  1009. vue.ref(false);
  1010. return (_ctx, _cache) => {
  1011. const _component_el_dialog = vue.resolveComponent("el-dialog");
  1012. const _component_el_input = vue.resolveComponent("el-input");
  1013. const _component_el_form_item = vue.resolveComponent("el-form-item");
  1014. const _component_el_form = vue.resolveComponent("el-form");
  1015. const _component_el_button = vue.resolveComponent("el-button");
  1016. const _component_el_progress = vue.resolveComponent("el-progress");
  1017. const _component_el_col = vue.resolveComponent("el-col");
  1018. const _component_el_option = vue.resolveComponent("el-option");
  1019. const _component_el_select = vue.resolveComponent("el-select");
  1020. const _component_el_tooltip = vue.resolveComponent("el-tooltip");
  1021. const _component_el_row = vue.resolveComponent("el-row");
  1022. const _component_el_table_column = vue.resolveComponent("el-table-column");
  1023. const _component_el_link = vue.resolveComponent("el-link");
  1024. const _component_el_switch = vue.resolveComponent("el-switch");
  1025. const _component_el_table = vue.resolveComponent("el-table");
  1026. return vue.openBlock(), vue.createElementBlock("div", null, [
  1027. vue.createVNode(_component_el_dialog, {
  1028. modelValue: q1.value,
  1029. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => q1.value = $event)
  1030. }, {
  1031. default: vue.withCtx(() => [
  1032. vue.createVNode(Q1)
  1033. ]),
  1034. _: 1
  1035. }, 8, ["modelValue"]),
  1036. vue.createVNode(_component_el_dialog, {
  1037. modelValue: dialogFormVisible.value,
  1038. "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => dialogFormVisible.value = $event),
  1039. title: `${info.status == "add" ? "添加" : "编辑"}`,
  1040. width: "400"
  1041. }, {
  1042. footer: vue.withCtx(() => [
  1043. vue.createElementVNode("div", _hoisted_1, [
  1044. vue.createVNode(_component_el_button, {
  1045. onClick: _cache[3] || (_cache[3] = ($event) => dialogFormVisible.value = false)
  1046. }, {
  1047. default: vue.withCtx(() => [
  1048. vue.createTextVNode("取消")
  1049. ]),
  1050. _: 1
  1051. }),
  1052. vue.createVNode(_component_el_button, { onClick: addOrUpdate }, {
  1053. default: vue.withCtx(() => [
  1054. vue.createTextVNode(" 确认 ")
  1055. ]),
  1056. _: 1
  1057. })
  1058. ])
  1059. ]),
  1060. default: vue.withCtx(() => [
  1061. vue.createVNode(_component_el_form, null, {
  1062. default: vue.withCtx(() => [
  1063. vue.createVNode(_component_el_form_item, {
  1064. label: "标题",
  1065. "label-width": formLabelWidth
  1066. }, {
  1067. default: vue.withCtx(() => [
  1068. vue.createVNode(_component_el_input, {
  1069. modelValue: info.title,
  1070. "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => info.title = $event),
  1071. autocomplete: "off"
  1072. }, null, 8, ["modelValue"])
  1073. ]),
  1074. _: 1
  1075. }),
  1076. vue.createVNode(_component_el_form_item, {
  1077. label: "链接",
  1078. "label-width": formLabelWidth
  1079. }, {
  1080. default: vue.withCtx(() => [
  1081. vue.createVNode(_component_el_input, {
  1082. modelValue: info.link,
  1083. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => info.link = $event),
  1084. autocomplete: "off"
  1085. }, null, 8, ["modelValue"])
  1086. ]),
  1087. _: 1
  1088. })
  1089. ]),
  1090. _: 1
  1091. })
  1092. ]),
  1093. _: 1
  1094. }, 8, ["modelValue", "title"]),
  1095. vue.createVNode(_component_el_dialog, {
  1096. modelValue: dialogTableVisible.value,
  1097. "onUpdate:modelValue": _cache[15] || (_cache[15] = ($event) => dialogTableVisible.value = $event),
  1098. title: asyncButtonLoadBreak.value ? `同步已中断 ${asyncProblemNum.value}/${allProblemNum.value}` : showProcess.value ? loadProcess.value < 100 ? `同步中...${asyncProblemNum.value}/${allProblemNum.value}` : "统计完成" : "题单信息",
  1099. width: "60%"
  1100. }, {
  1101. default: vue.withCtx(() => [
  1102. showProcess.value ? (vue.openBlock(), vue.createBlock(_component_el_progress, {
  1103. key: 0,
  1104. color: processColors,
  1105. percentage: loadProcess.value,
  1106. "stroke-width": 15,
  1107. striped: "",
  1108. "striped-flow": "",
  1109. style: { "margin-bottom": "20px" },
  1110. status: `${loadProcess.value == 100 ? "success" : ""}`
  1111. }, null, 8, ["percentage", "status"])) : vue.createCommentVNode("", true),
  1112. vue.createVNode(_component_el_row, { gutter: 10 }, {
  1113. default: vue.withCtx(() => [
  1114. vue.createVNode(_component_el_col, { span: 4 }, {
  1115. default: vue.withCtx(() => [
  1116. vue.createVNode(_component_el_input, {
  1117. modelValue: keywords.value,
  1118. "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => keywords.value = $event),
  1119. placeholder: "请输入关键词过滤",
  1120. clearable: ""
  1121. }, null, 8, ["modelValue"])
  1122. ]),
  1123. _: 1
  1124. }),
  1125. vue.createVNode(_component_el_col, { span: 20 }, {
  1126. default: vue.withCtx(() => [
  1127. showAddLocalButton.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1128. key: 0,
  1129. plain: "",
  1130. onClick: addlocal,
  1131. disabled: isDisabbled.value,
  1132. size: tableButtonSize.value
  1133. }, {
  1134. default: vue.withCtx(() => [
  1135. vue.createTextVNode(" 添加本页 ")
  1136. ]),
  1137. _: 1
  1138. }, 8, ["disabled", "size"])) : vue.createCommentVNode("", true),
  1139. showAddLocalButton.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1140. key: 1,
  1141. plain: "",
  1142. onClick: _cache[6] || (_cache[6] = ($event) => handlerProblems("add")),
  1143. size: tableButtonSize.value
  1144. }, {
  1145. default: vue.withCtx(() => [
  1146. vue.createTextVNode(" 自定义 ")
  1147. ]),
  1148. _: 1
  1149. }, 8, ["size"])) : vue.createCommentVNode("", true),
  1150. vue.createVNode(_component_el_select, {
  1151. modelValue: sortType.value,
  1152. "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => sortType.value = $event),
  1153. style: { "margin": "0 5px", "width": "100px" },
  1154. disabled: asyncButtonLoad.value
  1155. }, {
  1156. default: vue.withCtx(() => [
  1157. vue.createVNode(_component_el_option, {
  1158. label: "默认排序",
  1159. value: 0
  1160. }, {
  1161. default: vue.withCtx(() => [
  1162. vue.createTextVNode("默认排序")
  1163. ]),
  1164. _: 1
  1165. }),
  1166. vue.createVNode(_component_el_option, {
  1167. label: "题目数量",
  1168. value: 1
  1169. }, {
  1170. default: vue.withCtx(() => [
  1171. vue.createTextVNode("题目数量")
  1172. ]),
  1173. _: 1
  1174. }),
  1175. vue.createVNode(_component_el_option, {
  1176. label: "AC数量",
  1177. value: 2
  1178. }, {
  1179. default: vue.withCtx(() => [
  1180. vue.createTextVNode("AC数量")
  1181. ]),
  1182. _: 1
  1183. }),
  1184. vue.createVNode(_component_el_option, {
  1185. label: "完成度",
  1186. value: 3
  1187. }, {
  1188. default: vue.withCtx(() => [
  1189. vue.createTextVNode("完成度")
  1190. ]),
  1191. _: 1
  1192. })
  1193. ]),
  1194. _: 1
  1195. }, 8, ["modelValue", "disabled"]),
  1196. vue.createVNode(_component_el_tooltip, { content: "同步所有题单" }, {
  1197. default: vue.withCtx(() => [
  1198. vue.createVNode(_component_el_button, {
  1199. type: asyncButtonLoad.value ? "success" : "danger",
  1200. onClick: _cache[8] || (_cache[8] = ($event) => asyncProblemStatus({ "link": "https://leetcode.cn/u/endlesscheng/" })),
  1201. size: tableButtonSize.value,
  1202. loading: asyncButtonLoad.value
  1203. }, {
  1204. default: vue.withCtx(() => [
  1205. vue.createTextVNode(vue.toDisplayString(asyncButtonLoad.value ? "同步中" : "同步题单"), 1)
  1206. ]),
  1207. _: 1
  1208. }, 8, ["type", "size", "loading"])
  1209. ]),
  1210. _: 1
  1211. }),
  1212. asyncButtonLoad.value ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
  1213. key: 2,
  1214. content: "点击中断同步"
  1215. }, {
  1216. default: vue.withCtx(() => [
  1217. asyncButtonLoad.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1218. key: 0,
  1219. type: "warning",
  1220. text: "",
  1221. onClick: _cache[9] || (_cache[9] = ($event) => asyncButtonLoadBreak.value = !asyncButtonLoadBreak.value),
  1222. size: tableButtonSize.value
  1223. }, {
  1224. default: vue.withCtx(() => [
  1225. vue.createTextVNode(" 中断同步 ")
  1226. ]),
  1227. _: 1
  1228. }, 8, ["size"])) : vue.createCommentVNode("", true)
  1229. ]),
  1230. _: 1
  1231. })) : vue.createCommentVNode("", true),
  1232. vue.createVNode(_component_el_tooltip, { content: "随机一道灵茶题单中题目,快捷键 Ctrl + Alt + J 可以触发" }, {
  1233. default: vue.withCtx(() => [
  1234. vue.createVNode(_component_el_button, {
  1235. type: "primary",
  1236. text: "",
  1237. onClick: vue.unref(randomProblem),
  1238. size: tableButtonSize.value
  1239. }, {
  1240. default: vue.withCtx(() => [
  1241. vue.createTextVNode(" 随机题目 ")
  1242. ]),
  1243. _: 1
  1244. }, 8, ["onClick", "size"])
  1245. ]),
  1246. _: 1
  1247. })
  1248. ]),
  1249. _: 1
  1250. })
  1251. ]),
  1252. _: 1
  1253. }),
  1254. vue.createVNode(_component_el_table, {
  1255. data: vue.unref(urlsData),
  1256. height: "300",
  1257. style: { "width": "100%", "margin-top": "10px" }
  1258. }, {
  1259. default: vue.withCtx(() => [
  1260. vue.createVNode(_component_el_table_column, { type: "index" }),
  1261. vue.createVNode(_component_el_table_column, {
  1262. label: "标题",
  1263. width: "auto",
  1264. align: "center"
  1265. }, {
  1266. default: vue.withCtx((scope) => [
  1267. vue.createVNode(_component_el_link, {
  1268. href: scope.row.link,
  1269. target: "_blank",
  1270. type: "default"
  1271. }, {
  1272. default: vue.withCtx(() => [
  1273. vue.createTextVNode(vue.toDisplayString(scope.row.title), 1)
  1274. ]),
  1275. _: 2
  1276. }, 1032, ["href"])
  1277. ]),
  1278. _: 1
  1279. }),
  1280. vue.createVNode(_component_el_table_column, {
  1281. label: "随机",
  1282. width: "70",
  1283. align: "center"
  1284. }, {
  1285. default: vue.withCtx((scope) => [
  1286. vue.createVNode(_component_el_switch, {
  1287. modelValue: scope.row.select,
  1288. "onUpdate:modelValue": ($event) => scope.row.select = $event,
  1289. onChange: ($event) => selectHandlerChange(scope.row),
  1290. disabled: rowIsDisabled.value(scope.row),
  1291. size: "small"
  1292. }, null, 8, ["modelValue", "onUpdate:modelValue", "onChange", "disabled"])
  1293. ]),
  1294. _: 1
  1295. }),
  1296. vue.createVNode(_component_el_table_column, {
  1297. label: "AC",
  1298. width: "70",
  1299. align: "center"
  1300. }, {
  1301. default: vue.withCtx((scope) => [
  1302. vue.createVNode(_component_el_link, {
  1303. type: "success",
  1304. underline: false,
  1305. onClick: ($event) => showProblemsInfo(scope.row)
  1306. }, {
  1307. default: vue.withCtx(() => [
  1308. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.ac) ? 0 : scope.row.ac), 1)
  1309. ]),
  1310. _: 2
  1311. }, 1032, ["onClick"])
  1312. ]),
  1313. _: 1
  1314. }),
  1315. vue.createVNode(_component_el_table_column, {
  1316. label: "Total",
  1317. width: "70",
  1318. align: "center"
  1319. }, {
  1320. default: vue.withCtx((scope) => [
  1321. vue.createVNode(_component_el_link, {
  1322. type: "primary",
  1323. underline: false,
  1324. onClick: ($event) => showProblemsInfo(scope.row)
  1325. }, {
  1326. default: vue.withCtx(() => [
  1327. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.tot) ? 0 : scope.row.tot), 1)
  1328. ]),
  1329. _: 2
  1330. }, 1032, ["onClick"])
  1331. ]),
  1332. _: 1
  1333. }),
  1334. vue.createVNode(_component_el_table_column, {
  1335. label: "进度",
  1336. width: "70",
  1337. align: "center"
  1338. }, {
  1339. default: vue.withCtx((scope) => [
  1340. vue.createVNode(_component_el_link, {
  1341. onClick: ($event) => showProblemsInfo(scope.row),
  1342. type: "warning",
  1343. underline: false
  1344. }, {
  1345. default: vue.withCtx(() => {
  1346. var _a, _b, _c;
  1347. return [
  1348. vue.createTextVNode(vue.toDisplayString(((_a = scope == null ? void 0 : scope.row) == null ? void 0 : _a.tot) == 0 ? 0 : `${computeProcess((_b = scope == null ? void 0 : scope.row) == null ? void 0 : _b.ac, (_c = scope == null ? void 0 : scope.row) == null ? void 0 : _c.tot)}%`), 1)
  1349. ];
  1350. }),
  1351. _: 2
  1352. }, 1032, ["onClick"])
  1353. ]),
  1354. _: 1
  1355. }),
  1356. vue.createVNode(_component_el_table_column, {
  1357. label: "操作",
  1358. width: "200px",
  1359. align: "center"
  1360. }, {
  1361. default: vue.withCtx((scope) => [
  1362. vue.createVNode(_component_el_button, {
  1363. loading: scope.row.loading,
  1364. onClick: ($event) => asyncProblemStatus(scope.row),
  1365. size: "small",
  1366. type: "success",
  1367. disabled: rowIsDisabled.value(scope.row),
  1368. link: ""
  1369. }, {
  1370. default: vue.withCtx(() => [
  1371. vue.createTextVNode(vue.toDisplayString(scope.row.loading ? "" : "同步"), 1)
  1372. ]),
  1373. _: 2
  1374. }, 1032, ["loading", "onClick", "disabled"]),
  1375. vue.createVNode(_component_el_button, {
  1376. onClick: ($event) => handlerProblems("update", scope.row, scope.$index),
  1377. size: "small",
  1378. type: "primary",
  1379. disabled: rowIsDisabled.value(scope.row),
  1380. link: ""
  1381. }, {
  1382. default: vue.withCtx(() => [
  1383. vue.createTextVNode("编辑")
  1384. ]),
  1385. _: 2
  1386. }, 1032, ["onClick", "disabled"]),
  1387. vue.createVNode(_component_el_button, {
  1388. onClick: ($event) => deleteProblems(scope.row.id),
  1389. size: "small",
  1390. type: "danger",
  1391. link: "",
  1392. disabled: rowIsDisabled.value(scope.row)
  1393. }, {
  1394. default: vue.withCtx(() => [
  1395. vue.createTextVNode("删除")
  1396. ]),
  1397. _: 2
  1398. }, 1032, ["onClick", "disabled"])
  1399. ]),
  1400. _: 1
  1401. })
  1402. ]),
  1403. _: 1
  1404. }, 8, ["data"]),
  1405. vue.createVNode(_component_el_row, {
  1406. gutter: 10,
  1407. style: { "margin": "10px 0" }
  1408. }, {
  1409. default: vue.withCtx(() => [
  1410. vue.createVNode(_component_el_col, { span: 6 }, {
  1411. default: vue.withCtx(() => [
  1412. vue.createTextVNode(" 会员  "),
  1413. vue.createVNode(_component_el_tooltip, { content: "过滤会员题目,会员题不会出现在随机题目中,默认过滤" }, {
  1414. default: vue.withCtx(() => [
  1415. vue.createVNode(_component_el_switch, {
  1416. modelValue: fromData.visiableMember,
  1417. "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => fromData.visiableMember = $event)
  1418. }, null, 8, ["modelValue"])
  1419. ]),
  1420. _: 1
  1421. }),
  1422. vue.createTextVNode(" ac  "),
  1423. vue.createVNode(_component_el_tooltip, { content: "过滤AC的题目,AC题目出现在随机题目中,默认不过滤" }, {
  1424. default: vue.withCtx(() => [
  1425. vue.createVNode(_component_el_switch, {
  1426. modelValue: fromData.showAcConfig,
  1427. "onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => fromData.showAcConfig = $event)
  1428. }, null, 8, ["modelValue"])
  1429. ]),
  1430. _: 1
  1431. })
  1432. ]),
  1433. _: 1
  1434. }),
  1435. vue.createVNode(_component_el_col, { span: 10 }, {
  1436. default: vue.withCtx(() => [
  1437. vue.createTextVNode("   "),
  1438. vue.createVNode(_component_el_tooltip, { content: "随机题目将会随机在这个区间中的题目" }, {
  1439. default: vue.withCtx(() => [
  1440. vue.createVNode(_component_el_link, {
  1441. underline: false,
  1442. type: "primary"
  1443. }, {
  1444. default: vue.withCtx(() => [
  1445. vue.createTextVNode("分数区间")
  1446. ]),
  1447. _: 1
  1448. })
  1449. ]),
  1450. _: 1
  1451. }),
  1452. vue.createTextVNode("   "),
  1453. vue.createVNode(_component_el_input, {
  1454. modelValue: fromData.min,
  1455. "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => fromData.min = $event),
  1456. "aria-placeholder": "",
  1457. placeholder: " min ",
  1458. style: { "width": "60px" }
  1459. }, null, 8, ["modelValue"]),
  1460. vue.createTextVNode("- "),
  1461. vue.createVNode(_component_el_input, {
  1462. modelValue: fromData.max,
  1463. "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => fromData.max = $event),
  1464. "aria-placeholder": "",
  1465. placeholder: " max",
  1466. style: { "width": "60px" }
  1467. }, null, 8, ["modelValue"])
  1468. ]),
  1469. _: 1
  1470. }),
  1471. vue.createVNode(_component_el_col, { span: 8 }, {
  1472. default: vue.withCtx(() => [
  1473. vue.createVNode(_component_el_tooltip, { content: "重置题单" }, {
  1474. default: vue.withCtx(() => [
  1475. vue.createVNode(_component_el_button, {
  1476. plain: "",
  1477. onClick: handlerDefault,
  1478. size: tableButtonSize.value,
  1479. disabled: showProcess.value
  1480. }, {
  1481. default: vue.withCtx(() => [
  1482. vue.createTextVNode(" 默认 ")
  1483. ]),
  1484. _: 1
  1485. }, 8, ["size", "disabled"])
  1486. ]),
  1487. _: 1
  1488. }),
  1489. vue.createVNode(_component_el_button, {
  1490. plain: "",
  1491. onClick: _cache[14] || (_cache[14] = ($event) => q1.value = !q1.value),
  1492. size: tableButtonSize.value
  1493. }, {
  1494. default: vue.withCtx(() => [
  1495. vue.createTextVNode(" 使用说明 ")
  1496. ]),
  1497. _: 1
  1498. }, 8, ["size"])
  1499. ]),
  1500. _: 1
  1501. })
  1502. ]),
  1503. _: 1
  1504. })
  1505. ]),
  1506. _: 1
  1507. }, 8, ["modelValue", "title"]),
  1508. vue.createVNode(_component_el_dialog, {
  1509. modelValue: asyncVisableDialog.value,
  1510. "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => asyncVisableDialog.value = $event),
  1511. width: "35%"
  1512. }, {
  1513. default: vue.withCtx(() => [
  1514. vue.createElementVNode("p", null, [
  1515. vue.createVNode(_component_el_link, {
  1516. href: showProblemsProcessInfo.link,
  1517. type: "info",
  1518. underline: false
  1519. }, {
  1520. default: vue.withCtx(() => [
  1521. vue.createTextVNode(vue.toDisplayString(showProblemsProcessInfo.title), 1)
  1522. ]),
  1523. _: 1
  1524. }, 8, ["href"])
  1525. ]),
  1526. vue.createElementVNode("div", _hoisted_2, [
  1527. vue.createVNode(_component_el_progress, {
  1528. type: "circle",
  1529. percentage: computeProcess(showProblemsProcessInfo.ac, showProblemsProcessInfo.tot),
  1530. color: processColors
  1531. }, {
  1532. default: vue.withCtx(({ percentage }) => [
  1533. vue.createElementVNode("p", null, vue.toDisplayString(percentage) + "%", 1)
  1534. ]),
  1535. _: 1
  1536. }, 8, ["percentage"])
  1537. ]),
  1538. vue.createElementVNode("p", _hoisted_3, vue.toDisplayString(showProblemsProcessInfo.ac) + " / " + vue.toDisplayString(showProblemsProcessInfo.tot), 1)
  1539. ]),
  1540. _: 1
  1541. }, 8, ["modelValue"])
  1542. ]);
  1543. };
  1544. }
  1545. };
  1546. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-003e83a0"]]);
  1547. const cssLoader = (e) => {
  1548. const t = GM_getResourceText(e);
  1549. return GM_addStyle(t), t;
  1550. };
  1551. cssLoader("elementPlusCss");
  1552. const stopRankingKey = "__is_stop_rating_ranking__";
  1553. let conetstTimeId = null;
  1554. function run$1() {
  1555. const container = document.querySelector(".contest-question-info .list-group");
  1556. if (!container) return;
  1557. const ls = Array.from(container.querySelectorAll(".list-group-item .pull-right"));
  1558. for (let i = 0; i < 4; i++) {
  1559. if (i >= ls.length) {
  1560. break;
  1561. }
  1562. if (ls[i] instanceof HTMLElement) {
  1563. ls[i].textContent = "0";
  1564. }
  1565. }
  1566. window.clearInterval(conetstTimeId);
  1567. }
  1568. function startStopRanking() {
  1569. if (!isContest(window.location.href)) {
  1570. return;
  1571. }
  1572. const isNext = !!document.querySelector("#__next");
  1573. if (isNext) {
  1574. return;
  1575. }
  1576. const use = Cache$1.get(stopRankingKey);
  1577. if (use) {
  1578. conetstTimeId = setInterval(() => {
  1579. run$1();
  1580. }, 10);
  1581. }
  1582. _GM_registerMenuCommand(`${use ? "使用" : "关闭"} 排行榜`, () => {
  1583. Cache$1.set(stopRankingKey, !use);
  1584. window.location.reload();
  1585. }, { title: "对于不想看到排行榜的可以使用此功能 默认开启" });
  1586. }
  1587. const local_url = window.location.href;
  1588. let loadID = 0;
  1589. let submitCnt = 0;
  1590. function watchDom(dom2) {
  1591. if (!(dom2 instanceof HTMLElement)) {
  1592. return;
  1593. }
  1594. let m = new MutationObserver(() => {
  1595. if (submitCnt % 2 == 1) {
  1596. submitProblems(local_url);
  1597. }
  1598. submitCnt++;
  1599. });
  1600. m.observe(dom2, {
  1601. childList: true,
  1602. attributes: true
  1603. });
  1604. }
  1605. const randomProblemKey = () => Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_random_problems_key__"]) == void 0 ? true : Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_random_problems_key__"]);
  1606. let Container = null;
  1607. Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_button_is_none__"], true, Boolean.name);
  1608. const start = () => {
  1609. Container = document.createElement("div");
  1610. const body = document.querySelector("body");
  1611. body.append(Container);
  1612. Container.style.display = "block";
  1613. return Container;
  1614. };
  1615. let dom = start();
  1616. const VueApp = vue.createApp(App);
  1617. VueApp.use(ElementPlus).mount(dom);
  1618. if (isProblem() || isLeetCodeCircleUrl()) {
  1619. _GM_registerMenuCommand(`随机一道题 ☕`, randomProblem, { title: "随机一道题目,你可以通过ctrl+atl+j显示一道题目" });
  1620. _GM_registerMenuCommand(`${randomProblemKey() ? "关闭" : "启用"} 随机题目快捷键 ☕`, () => {
  1621. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_random_problems_key__"], !randomProblemKey());
  1622. window.location.reload();
  1623. }, { title: "该功能是随机一道题的快捷键,你可以通过ctrl+atl+j显示一道题目" });
  1624. if (randomProblemKey()) {
  1625. document.addEventListener("keydown", async function(event) {
  1626. if (event.ctrlKey && event.altKey && event.key === "j") {
  1627. randomProblem();
  1628. }
  1629. });
  1630. }
  1631. }
  1632. function run() {
  1633. loadID++;
  1634. if (isProblem(local_url) || isContest(local_url)) {
  1635. if (isProblem(local_url) && loadID == 1) {
  1636. submitProblems(local_url);
  1637. }
  1638. setTimeout(() => {
  1639. let submitbutton = null;
  1640. const isNext = !!document.querySelector("#__next");
  1641. if (isProblem(local_url) || isNext) {
  1642. submitbutton = document.querySelector("div [data-e2e-locator=console-submit-button]");
  1643. } else {
  1644. let buttons = Array.from(document.querySelectorAll(".question-detail-bottom .pull-right button"));
  1645. for (let i = buttons.length - 1; i >= 0; i--) {
  1646. if (buttons[i].textContent.indexOf("提交解答") != -1) {
  1647. submitbutton = buttons[i];
  1648. break;
  1649. }
  1650. }
  1651. }
  1652. if (submitbutton) {
  1653. submitbutton.addEventListener("click", () => {
  1654. submitProblems(local_url, 10 * 1e3);
  1655. });
  1656. watchDom(submitbutton);
  1657. } else if (loadID < 10) {
  1658. run();
  1659. }
  1660. }, 3e3);
  1661. } else if (isLeetCodeCircleUrl(local_url)) {
  1662. _GM_registerMenuCommand(`安装到${install_pos() ? "右侧" : "左侧"} 🎁`, () => {
  1663. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_insert_pos__"], install_pos());
  1664. window.location.reload();
  1665. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  1666. _GM_registerMenuCommand(`清空题目状态缓存 🚀`, () => {
  1667. Message("确认清空题目状态缓存", () => {
  1668. deleteAllACCountKeys();
  1669. window.location.reload();
  1670. });
  1671. }, { title: "如果题目状态出现问题,可以试试,一般情况下不建议使用" });
  1672. _GM_registerMenuCommand(`同步题目状态 🚀`, () => {
  1673. Message("确认同步题目状态", async () => {
  1674. await addProcess(true, void 0, true);
  1675. });
  1676. }, { title: "如果不在同一个浏览器答题,会出现ac题目状态没有及时同步,可以使用此功能" });
  1677. _GM_registerMenuCommand(`${initObj().onlyUrls ? "仅在收藏题单页面生效" : "所有题单生效"}`, () => {
  1678. const u = initObj();
  1679. u.onlyUrls = !u.onlyUrls;
  1680. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"], u);
  1681. }, { title: "插件默认会在所有讨论发布页生效,如果只想在收藏链接生效,可以使用此功能" });
  1682. _GM_registerMenuCommand(`添加本页`, () => {
  1683. const urls = initUrls();
  1684. let ok = false;
  1685. let url = window.location.href;
  1686. for (let info of urls) {
  1687. if (!info || !(info == null ? void 0 : info.link)) {
  1688. continue;
  1689. }
  1690. if (info.link.indexOf(url) != -1) {
  1691. ok = true;
  1692. break;
  1693. }
  1694. }
  1695. if (ok) {
  1696. ElementPlus.ElMessage({
  1697. message: "收藏失败,链接已经存在!",
  1698. type: "error"
  1699. });
  1700. } else {
  1701. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  1702. try {
  1703. url = url.split("view")[0];
  1704. } catch (e) {
  1705. url = window.location.href;
  1706. }
  1707. }
  1708. urls.unshift({
  1709. title: document.title,
  1710. link: url
  1711. });
  1712. Container.style.display = "block";
  1713. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], urls);
  1714. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true);
  1715. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"], true);
  1716. ElementPlus.ElMessage({
  1717. message: "收藏成功!刷新生效",
  1718. type: "success"
  1719. });
  1720. }
  1721. });
  1722. }
  1723. }
  1724. run();
  1725. startStopRanking();
  1726.  
  1727. })(Vue, ElementPlus);