0x3f-problem-solution

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

Stan na 15-10-2024. Zobacz najnowsza wersja.

  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. for (let info of allProbmems) {
  544. if (!(info == null ? void 0 : info.problemUrl) || !set.has(info == null ? void 0 : info.problemUrl) || !Array.isArray(info.problems) || info.problems.length == 0) {
  545. continue;
  546. }
  547. for (let i = 0; Array.isArray(info.problems) && i < info.problems.length; i++) {
  548. try {
  549. let { title, url, member, score, titleSlug } = info.problems[i];
  550. if (!url || !title) continue;
  551. if (isDev()) ;
  552. if (!(config == null ? void 0 : config.showAcConfig) && acMap[titleSlug] == "ac") {
  553. continue;
  554. }
  555. if (!(config == null ? void 0 : config.visiableMember) && member) {
  556. continue;
  557. }
  558. if (score != 0 && (score < (config == null ? void 0 : config.min) || score > (config == null ? void 0 : config.max))) {
  559. continue;
  560. }
  561. infos.push({ title, url, member, score, titleSlug, "status": acMap[titleSlug] });
  562. } catch (e) {
  563. console.log("error", e);
  564. }
  565. }
  566. }
  567. let data = getRandomInfo(infos);
  568. ElementPlus.ElMessage({
  569. dangerouslyUseHTMLString: !!(data && (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title)),
  570. type: (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title) ? "success" : "error",
  571. 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>` : `没有符合条件的题目,请重新配置条件!`,
  572. duration: 6e3
  573. });
  574. }
  575. async function GetHubJSONInfo(url) {
  576. return fetch(url, {
  577. method: "get",
  578. mode: "cors"
  579. }).then((res) => res.json());
  580. }
  581. async function getProblemsJSON() {
  582. return GetHubJSONInfo("https://raw.githubusercontent.com/wuxin0011/tampermonkey-script/main/0x3f-leetcode/0x3f.json");
  583. }
  584. async function PostLeetCodeApi(data) {
  585. return fetch("https://leetcode.cn/graphql/", {
  586. method: "POST",
  587. credentials: "include",
  588. headers: {
  589. "Content-Type": "application/json"
  590. },
  591. body: JSON.stringify(data)
  592. }).then((res) => res.json());
  593. }
  594. async function getProblemAcInfo(titleSlug) {
  595. return PostLeetCodeApi(postData(titleSlug));
  596. }
  597. const _export_sfc = (sfc, props) => {
  598. const target = sfc.__vccOpts || sfc;
  599. for (const [key, val] of props) {
  600. target[key] = val;
  601. }
  602. return target;
  603. };
  604. const _sfc_main$1 = {};
  605. 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);
  606. function _sfc_render(_ctx, _cache) {
  607. const _component_el_link = vue.resolveComponent("el-link");
  608. return vue.openBlock(), vue.createElementBlock("div", null, [
  609. _hoisted_1$1,
  610. vue.createElementVNode("p", null, [
  611. vue.createTextVNode("你可以"),
  612. vue.createVNode(_component_el_link, {
  613. underline: false,
  614. href: "https://greatest.deepsurf.us/zh-CN/scripts/501134-0x3f-problem-solution/feedback",
  615. type: "primary",
  616. target: "_blank"
  617. }, {
  618. default: vue.withCtx(() => [
  619. vue.createTextVNode("点击")
  620. ]),
  621. _: 1
  622. }),
  623. vue.createTextVNode("这里反馈 ,或者访问 github 提一个 "),
  624. vue.createVNode(_component_el_link, {
  625. target: "_blank",
  626. underline: false,
  627. href: "https://github.com/wuxin0011/tampermonkey-script/issues",
  628. type: "primary"
  629. }, {
  630. default: vue.withCtx(() => [
  631. vue.createTextVNode("issues")
  632. ]),
  633. _: 1
  634. })
  635. ])
  636. ]);
  637. }
  638. const Q1 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-49e5e62d"]]);
  639. function Message(title = "确认操作", callback = () => {
  640. }, canlcelCallback = () => {
  641. }) {
  642. ElementPlus.ElMessageBox.confirm(
  643. `${title} ?`,
  644. "警告",
  645. {
  646. confirmButtonText: "确认",
  647. cancelButtonText: "取消",
  648. type: "warning"
  649. }
  650. ).then(() => {
  651. callback();
  652. }).catch(() => {
  653. ElementPlus.ElMessage({
  654. type: "info",
  655. message: "已取消"
  656. });
  657. canlcelCallback();
  658. });
  659. }
  660. const _hoisted_1 = { class: "dialog-footer" };
  661. const _hoisted_2 = { class: "processs-flex" };
  662. const _hoisted_3 = { style: { "text-align": "center", "color": "#121212" } };
  663. const TARGET_URL = "https://leetcode.cn/u/endlesscheng/";
  664. const formLabelWidth = "44px";
  665. const _sfc_main = {
  666. __name: "App",
  667. setup(__props) {
  668. const sortType = vue.ref(0);
  669. const tableButtonSize = vue.ref("default");
  670. let tableData = vue.reactive(initUrls());
  671. const keywords = vue.ref("");
  672. const dialogTableVisible = vue.ref(false);
  673. const showAddLocalButton = vue.computed(() => isLeetCodeCircleUrl());
  674. let urlsData = vue.computed(() => {
  675. let map = /* @__PURE__ */ new Map();
  676. let infos = tableData.filter((info2) => {
  677. if ((info2 == null ? void 0 : info2.title) && (info2 == null ? void 0 : info2.link) && !map.has(info2.link)) {
  678. map.set(info2.link, info2);
  679. return info2 && (info2.title && info2.title.indexOf(keywords.value) != -1 || info2.link && info2.link.indexOf(keywords.value) != -1);
  680. } else {
  681. return false;
  682. }
  683. });
  684. let tot = 0, ac = 0;
  685. for (let i = 0, c = info.length; i < infos.length; i++) {
  686. let info2 = infos[i];
  687. if (info2["ac"] && info2["tot"]) {
  688. tot += info2["tot"];
  689. ac += info2["ac"];
  690. }
  691. if (!info2["id"]) {
  692. info2["id"] = c + 1;
  693. c++;
  694. }
  695. }
  696. let type = sortType.value;
  697. if (type == 0) {
  698. infos.sort((info1, info2) => info2.id - info1.id);
  699. } else if (type == 1) {
  700. infos.sort((info1, info2) => info2.tot - info1.tot);
  701. } else if (type == 2) {
  702. infos.sort((info1, info2) => info2.ac - info1.ac);
  703. } else if (type == 3) {
  704. infos.sort((info1, info2) => computeProcess(info2.ac, info2.tot) - computeProcess(info1.ac, info1.tot));
  705. }
  706. infos.unshift({ "title": "灵茶题单完成情况", "link": TARGET_URL, "tot": tot, "ac": ac, "id": 67108863 });
  707. return infos;
  708. });
  709. const rowIsDisabled = vue.computed(() => (info2) => asyncButtonLoad.value || info2 && info2.link == TARGET_URL);
  710. const isDisabbled = vue.computed(() => !!tableData.find((v) => (v == null ? void 0 : v.link) && (v == null ? void 0 : v.link.indexOf(window.location.href)) != -1));
  711. const dialogFormVisible = vue.ref(false);
  712. const computeProcess = (ac = 0, tot = 0) => {
  713. if (isNaN(ac) || isNaN(tot) || tot === 0) return 0;
  714. let p = 0;
  715. if (tot == ac) {
  716. return 100;
  717. }
  718. const s = String(ac / tot);
  719. try {
  720. let x1 = s.split(".")[1] || "";
  721. x1 = x1.padEnd(3, "0").substring(0, 3);
  722. p = Math.min(100, Number(x1) / 10);
  723. } catch (e) {
  724. console.log("calc error", e.message, s == void 0, ac, tot);
  725. p = (ac / tot).toFixed(3) * 100;
  726. }
  727. return isNaN(p) ? 0 : p;
  728. };
  729. const processColors = [
  730. { color: "#f56c6c", percentage: 20 },
  731. { color: "#1989fa", percentage: 40 },
  732. { color: "#e6a23c", percentage: 60 },
  733. { color: "#6f7ad3", percentage: 80 },
  734. { color: "#67c23a", percentage: 100 }
  735. ];
  736. const fromData = vue.reactive(initObj());
  737. vue.watch(fromData, () => {
  738. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  739. });
  740. const info = vue.reactive({
  741. title: "",
  742. link: "",
  743. status: "add"
  744. });
  745. const addlocal = () => {
  746. if (!isDisabbled) {
  747. return;
  748. }
  749. let [cur, tot] = getProcess();
  750. tableData.unshift({ title: document.title, link: window.location.href, "ac": cur, "tot": tot, "id": tableData.length + 10 });
  751. };
  752. const updateIndex = vue.ref(-1);
  753. const handlerProblems = (status, updateInfo = { title: "", link: "", id: 0 }, index = -1) => {
  754. dialogFormVisible.value = true;
  755. info.status = status;
  756. updateIndex.value = updateInfo.id;
  757. Object.assign(info, updateInfo);
  758. };
  759. const handlerMessage = (u, title, link) => {
  760. const a = u ? "添加" : "修改";
  761. const error = !(!!title && isHttp(link));
  762. if (error) {
  763. ElementPlus.ElMessage.error(`${a} 失败 请保证标题或者链接有效 `);
  764. } else {
  765. ElementPlus.ElMessage.success(`${a} 成功 `);
  766. }
  767. return !error;
  768. };
  769. const addOrUpdate = () => {
  770. if (!handlerMessage(info.status == "add", info.title, info.link)) {
  771. return;
  772. }
  773. if (info.status == "add") {
  774. tableData.unshift({ title: info.title, link: info.link, "ac": 0, "tot": 0, "id": tableData.length + 10 });
  775. } else {
  776. let id = updateIndex.value;
  777. for (let i = 0; i < tableData.length; i++) {
  778. if (tableData[i] && tableData[i].id && tableData[i]["id"] == id) {
  779. tableData[i]["title"] = info.title;
  780. tableData[i]["link"] = info.link;
  781. break;
  782. }
  783. }
  784. }
  785. dialogFormVisible.value = false;
  786. };
  787. const deleteProblems = (id) => {
  788. for (let i = 0; i < tableData.length; i++) {
  789. if (tableData[i] && tableData[i].id && tableData[i]["id"] == id) {
  790. delete tableData[i];
  791. break;
  792. }
  793. }
  794. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  795. };
  796. const handlerDefault = () => {
  797. Message("确认使用默认题单,将会重置题单", () => {
  798. for (let i = 0; i < tableData.length; i++) {
  799. delete tableData[i];
  800. }
  801. let infos = computeAcInfo(defaultUrls);
  802. for (let item of infos) {
  803. tableData.unshift(item);
  804. }
  805. ElementPlus.ElMessage({
  806. type: "success",
  807. message: "重置成功"
  808. });
  809. });
  810. };
  811. window.addEventListener("beforeunload", () => {
  812. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData).filter((u) => u != null && u != void 0));
  813. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true);
  814. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"], false);
  815. });
  816. vue.onMounted(async () => {
  817. if (support_plugins()) {
  818. let times = 30;
  819. let loadTimeId = setInterval(() => {
  820. let a = queryProblem();
  821. times--;
  822. if (Array.isArray(a) && a.length > 0) {
  823. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  824. addProcess();
  825. window.clearInterval(loadTimeId);
  826. }
  827. if (times == 0) {
  828. window.clearInterval(loadTimeId);
  829. }
  830. }, 200);
  831. }
  832. window.addEventListener("storage", (e) => {
  833. watchLinkStatusUpdate(e);
  834. });
  835. });
  836. _GM_registerMenuCommand(`题单配置信息🛠`, () => {
  837. dialogTableVisible.value = !dialogTableVisible.value;
  838. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  839. const selectHandlerChange = (row) => {
  840. let infos = [];
  841. for (let i = 0; i < urlsData.value.length; i++) {
  842. if (urlsData.value[i]["link"] == TARGET_URL) continue;
  843. infos.push(vue.toRaw(Object.assign({}, urlsData.value[i])));
  844. }
  845. for (let i = 0; i < tableData.length; i++) {
  846. if (row.id == tableData[i].id) {
  847. tableData[i].select = row.select;
  848. break;
  849. }
  850. }
  851. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], infos);
  852. };
  853. const asyncButtonLoad = vue.ref(false);
  854. const asyncButtonLoadBreak = vue.ref(false);
  855. const showProcess = vue.ref(false);
  856. const allProblemNum = vue.ref(0);
  857. const asyncProblemNum = vue.ref(0);
  858. const asyncVisableDialog = vue.ref(false);
  859. const showProblemsProcessInfo = vue.reactive({
  860. title: "",
  861. link: "",
  862. cnt: "",
  863. ac: "",
  864. id: "",
  865. select: true
  866. });
  867. const showProblemsInfo = (info2 = {}) => {
  868. asyncVisableDialog.value = !asyncVisableDialog.value;
  869. Object.assign(showProblemsProcessInfo, info2);
  870. };
  871. const loadProcess = vue.computed(() => computeProcess(asyncProblemNum.value, allProblemNum.value));
  872. const asyncProblemStatus = async (row = {}) => {
  873. if (!(row == null ? void 0 : row.link)) return;
  874. let callback = async () => {
  875. var _a, _b, _c, _d, _e;
  876. let rowData = void 0;
  877. let asyncAll = (row == null ? void 0 : row.link) == TARGET_URL;
  878. let cache = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], true, Object.name);
  879. let map = /* @__PURE__ */ new Map();
  880. try {
  881. for (let info2 of tableData) {
  882. if ((info2 == null ? void 0 : info2.link) && (info2 == null ? void 0 : info2.title) && (info2 == null ? void 0 : info2.id)) {
  883. if (rowData == void 0 && (info2 == null ? void 0 : info2.id) == row.id) {
  884. rowData = info2;
  885. }
  886. if (!map.has(info2.link)) {
  887. map.set(info2.link, info2);
  888. }
  889. }
  890. }
  891. if (rowData) {
  892. rowData.loading = true;
  893. }
  894. asyncButtonLoad.value = true;
  895. asyncButtonLoadBreak.value = false;
  896. allProblemNum.value = 0;
  897. asyncProblemNum.value = 0;
  898. showProcess.value = true;
  899. await sleep(500);
  900. let jsonInfo = await getProblemsJSON();
  901. if (!Array.isArray(jsonInfo)) {
  902. jsonInfo = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_all_problems__"], true, Array.name);
  903. } else {
  904. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_all_problems__"], jsonInfo);
  905. }
  906. let datas = [];
  907. for (let i = 0; Array.isArray(jsonInfo) && i < jsonInfo.length; i++) {
  908. let key = `${(_a = jsonInfo[i]) == null ? void 0 : _a.problemUrl}`;
  909. let origin = map.get(key);
  910. if (!origin) {
  911. continue;
  912. }
  913. if (asyncAll) {
  914. for (let p of jsonInfo[i].problems) {
  915. datas.push(Object.assign({ "origin": jsonInfo[i].problemUrl }, p));
  916. }
  917. origin.tot = Math.max(jsonInfo[i].problems.length, (origin == null ? void 0 : origin.tot) ?? 0);
  918. origin.ac = 0;
  919. } else if (jsonInfo[i].problemUrl == row.link) {
  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. break;
  926. }
  927. }
  928. if (Array.isArray(datas) && datas.length > 0) {
  929. allProblemNum.value = datas.length;
  930. asyncProblemNum.value = 0;
  931. let pre = 0;
  932. for (let i = 0; i < datas.length; i++) {
  933. let info2 = datas[i];
  934. try {
  935. if (asyncButtonLoadBreak.value) {
  936. break;
  937. }
  938. await sleep(200);
  939. let ID = info2.titleSlug;
  940. let key = `${info2.origin}`;
  941. let origin = map.get(key);
  942. if (cache[ID] != "ac") {
  943. let response = await getProblemAcInfo(ID);
  944. const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status;
  945. cache[ID] = status == null ? "null" : status;
  946. }
  947. if (origin) {
  948. if (cache[ID] == "ac") {
  949. origin.ac = origin.ac + 1;
  950. }
  951. }
  952. if (isDev()) ;
  953. asyncProblemNum.value += 1;
  954. if (loadProcess.value < pre && isDev()) {
  955. console.warn("calc result is error");
  956. }
  957. pre = loadProcess.value;
  958. } catch (e) {
  959. if (isDev()) ;
  960. }
  961. if (i % 100 == 0) {
  962. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], Object.assign({}, cache));
  963. }
  964. }
  965. }
  966. } catch (e) {
  967. console.log("error", e);
  968. } finally {
  969. if (rowData) {
  970. rowData.loading = false;
  971. }
  972. asyncButtonLoad.value = false;
  973. for (let i = 0; i < tableData.length; i++) {
  974. if (getAcCountKey((_d = tableData[i]) == null ? void 0 : _d.link)) {
  975. Cache$1.set(getAcCountKey(tableData[i].link), { "tot": tableData[i].tot, "ac": tableData[i].ac });
  976. }
  977. if ((_e = tableData[i]) == null ? void 0 : _e.loading) {
  978. tableData[i].loading = false;
  979. }
  980. }
  981. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  982. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], Object.assign({}, cache));
  983. await sleep(500);
  984. ElementPlus.ElMessage({
  985. type: allProblemNum.value == asyncProblemNum.value ? "success" : asyncButtonLoadBreak.value ? "error" : "warning",
  986. message: allProblemNum.value == asyncProblemNum.value ? `同步完成🥰` : asyncButtonLoadBreak.value ? `同步中断 ${loadProcess.value}% ` : `同步率 ${loadProcess.value}% `,
  987. duration: 3e3
  988. });
  989. await sleep(6e3);
  990. allProblemNum.value = 0;
  991. asyncProblemNum.value = 0;
  992. showProcess.value = false;
  993. asyncButtonLoadBreak.value = false;
  994. }
  995. };
  996. if (row.link == TARGET_URL) {
  997. Message("该操作将同步所有题单,耗时可能较长 确认操作?", callback);
  998. } else {
  999. callback();
  1000. }
  1001. };
  1002. const q1 = vue.ref(false);
  1003. vue.ref(false);
  1004. return (_ctx, _cache) => {
  1005. const _component_el_dialog = vue.resolveComponent("el-dialog");
  1006. const _component_el_input = vue.resolveComponent("el-input");
  1007. const _component_el_form_item = vue.resolveComponent("el-form-item");
  1008. const _component_el_form = vue.resolveComponent("el-form");
  1009. const _component_el_button = vue.resolveComponent("el-button");
  1010. const _component_el_progress = vue.resolveComponent("el-progress");
  1011. const _component_el_col = vue.resolveComponent("el-col");
  1012. const _component_el_option = vue.resolveComponent("el-option");
  1013. const _component_el_select = vue.resolveComponent("el-select");
  1014. const _component_el_tooltip = vue.resolveComponent("el-tooltip");
  1015. const _component_el_row = vue.resolveComponent("el-row");
  1016. const _component_el_table_column = vue.resolveComponent("el-table-column");
  1017. const _component_el_link = vue.resolveComponent("el-link");
  1018. const _component_el_switch = vue.resolveComponent("el-switch");
  1019. const _component_el_table = vue.resolveComponent("el-table");
  1020. return vue.openBlock(), vue.createElementBlock("div", null, [
  1021. vue.createVNode(_component_el_dialog, {
  1022. modelValue: q1.value,
  1023. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => q1.value = $event)
  1024. }, {
  1025. default: vue.withCtx(() => [
  1026. vue.createVNode(Q1)
  1027. ]),
  1028. _: 1
  1029. }, 8, ["modelValue"]),
  1030. vue.createVNode(_component_el_dialog, {
  1031. modelValue: dialogFormVisible.value,
  1032. "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => dialogFormVisible.value = $event),
  1033. title: `${info.status == "add" ? "添加" : "编辑"}`,
  1034. width: "400"
  1035. }, {
  1036. footer: vue.withCtx(() => [
  1037. vue.createElementVNode("div", _hoisted_1, [
  1038. vue.createVNode(_component_el_button, {
  1039. onClick: _cache[3] || (_cache[3] = ($event) => dialogFormVisible.value = false)
  1040. }, {
  1041. default: vue.withCtx(() => [
  1042. vue.createTextVNode("取消")
  1043. ]),
  1044. _: 1
  1045. }),
  1046. vue.createVNode(_component_el_button, { onClick: addOrUpdate }, {
  1047. default: vue.withCtx(() => [
  1048. vue.createTextVNode(" 确认 ")
  1049. ]),
  1050. _: 1
  1051. })
  1052. ])
  1053. ]),
  1054. default: vue.withCtx(() => [
  1055. vue.createVNode(_component_el_form, null, {
  1056. default: vue.withCtx(() => [
  1057. vue.createVNode(_component_el_form_item, {
  1058. label: "标题",
  1059. "label-width": formLabelWidth
  1060. }, {
  1061. default: vue.withCtx(() => [
  1062. vue.createVNode(_component_el_input, {
  1063. modelValue: info.title,
  1064. "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => info.title = $event),
  1065. autocomplete: "off"
  1066. }, null, 8, ["modelValue"])
  1067. ]),
  1068. _: 1
  1069. }),
  1070. vue.createVNode(_component_el_form_item, {
  1071. label: "链接",
  1072. "label-width": formLabelWidth
  1073. }, {
  1074. default: vue.withCtx(() => [
  1075. vue.createVNode(_component_el_input, {
  1076. modelValue: info.link,
  1077. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => info.link = $event),
  1078. autocomplete: "off"
  1079. }, null, 8, ["modelValue"])
  1080. ]),
  1081. _: 1
  1082. })
  1083. ]),
  1084. _: 1
  1085. })
  1086. ]),
  1087. _: 1
  1088. }, 8, ["modelValue", "title"]),
  1089. vue.createVNode(_component_el_dialog, {
  1090. modelValue: dialogTableVisible.value,
  1091. "onUpdate:modelValue": _cache[15] || (_cache[15] = ($event) => dialogTableVisible.value = $event),
  1092. title: asyncButtonLoadBreak.value ? `同步已中断 ${asyncProblemNum.value}/${allProblemNum.value}` : showProcess.value ? loadProcess.value < 100 ? `同步中...${asyncProblemNum.value}/${allProblemNum.value}` : "统计完成" : "题单信息",
  1093. width: "60%"
  1094. }, {
  1095. default: vue.withCtx(() => [
  1096. showProcess.value ? (vue.openBlock(), vue.createBlock(_component_el_progress, {
  1097. key: 0,
  1098. color: processColors,
  1099. percentage: loadProcess.value,
  1100. "stroke-width": 15,
  1101. striped: "",
  1102. "striped-flow": "",
  1103. style: { "margin-bottom": "20px" },
  1104. status: `${loadProcess.value == 100 ? "success" : ""}`
  1105. }, null, 8, ["percentage", "status"])) : vue.createCommentVNode("", true),
  1106. vue.createVNode(_component_el_row, { gutter: 10 }, {
  1107. default: vue.withCtx(() => [
  1108. vue.createVNode(_component_el_col, { span: 4 }, {
  1109. default: vue.withCtx(() => [
  1110. vue.createVNode(_component_el_input, {
  1111. modelValue: keywords.value,
  1112. "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => keywords.value = $event),
  1113. placeholder: "请输入关键词过滤",
  1114. clearable: ""
  1115. }, null, 8, ["modelValue"])
  1116. ]),
  1117. _: 1
  1118. }),
  1119. vue.createVNode(_component_el_col, { span: 20 }, {
  1120. default: vue.withCtx(() => [
  1121. showAddLocalButton.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1122. key: 0,
  1123. plain: "",
  1124. onClick: addlocal,
  1125. disabled: isDisabbled.value,
  1126. size: tableButtonSize.value
  1127. }, {
  1128. default: vue.withCtx(() => [
  1129. vue.createTextVNode(" 添加本页 ")
  1130. ]),
  1131. _: 1
  1132. }, 8, ["disabled", "size"])) : vue.createCommentVNode("", true),
  1133. showAddLocalButton.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1134. key: 1,
  1135. plain: "",
  1136. onClick: _cache[6] || (_cache[6] = ($event) => handlerProblems("add")),
  1137. size: tableButtonSize.value
  1138. }, {
  1139. default: vue.withCtx(() => [
  1140. vue.createTextVNode(" 自定义 ")
  1141. ]),
  1142. _: 1
  1143. }, 8, ["size"])) : vue.createCommentVNode("", true),
  1144. vue.createVNode(_component_el_select, {
  1145. modelValue: sortType.value,
  1146. "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => sortType.value = $event),
  1147. style: { "margin": "0 5px", "width": "100px" },
  1148. disabled: asyncButtonLoad.value
  1149. }, {
  1150. default: vue.withCtx(() => [
  1151. vue.createVNode(_component_el_option, {
  1152. label: "默认排序",
  1153. value: 0
  1154. }, {
  1155. default: vue.withCtx(() => [
  1156. vue.createTextVNode("默认排序")
  1157. ]),
  1158. _: 1
  1159. }),
  1160. vue.createVNode(_component_el_option, {
  1161. label: "题目数量",
  1162. value: 1
  1163. }, {
  1164. default: vue.withCtx(() => [
  1165. vue.createTextVNode("题目数量")
  1166. ]),
  1167. _: 1
  1168. }),
  1169. vue.createVNode(_component_el_option, {
  1170. label: "AC数量",
  1171. value: 2
  1172. }, {
  1173. default: vue.withCtx(() => [
  1174. vue.createTextVNode("AC数量")
  1175. ]),
  1176. _: 1
  1177. }),
  1178. vue.createVNode(_component_el_option, {
  1179. label: "完成度",
  1180. value: 3
  1181. }, {
  1182. default: vue.withCtx(() => [
  1183. vue.createTextVNode("完成度")
  1184. ]),
  1185. _: 1
  1186. })
  1187. ]),
  1188. _: 1
  1189. }, 8, ["modelValue", "disabled"]),
  1190. vue.createVNode(_component_el_tooltip, { content: "同步所有题单" }, {
  1191. default: vue.withCtx(() => [
  1192. vue.createVNode(_component_el_button, {
  1193. type: asyncButtonLoad.value ? "success" : "danger",
  1194. onClick: _cache[8] || (_cache[8] = ($event) => asyncProblemStatus({ "link": "https://leetcode.cn/u/endlesscheng/" })),
  1195. size: tableButtonSize.value,
  1196. loading: asyncButtonLoad.value
  1197. }, {
  1198. default: vue.withCtx(() => [
  1199. vue.createTextVNode(vue.toDisplayString(asyncButtonLoad.value ? "同步中" : "同步题单"), 1)
  1200. ]),
  1201. _: 1
  1202. }, 8, ["type", "size", "loading"])
  1203. ]),
  1204. _: 1
  1205. }),
  1206. asyncButtonLoad.value ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
  1207. key: 2,
  1208. content: "点击中断同步"
  1209. }, {
  1210. default: vue.withCtx(() => [
  1211. asyncButtonLoad.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1212. key: 0,
  1213. type: "warning",
  1214. text: "",
  1215. onClick: _cache[9] || (_cache[9] = ($event) => asyncButtonLoadBreak.value = !asyncButtonLoadBreak.value),
  1216. size: tableButtonSize.value
  1217. }, {
  1218. default: vue.withCtx(() => [
  1219. vue.createTextVNode(" 中断同步 ")
  1220. ]),
  1221. _: 1
  1222. }, 8, ["size"])) : vue.createCommentVNode("", true)
  1223. ]),
  1224. _: 1
  1225. })) : vue.createCommentVNode("", true),
  1226. vue.createVNode(_component_el_tooltip, { content: "随机一道灵茶题单中题目,快捷键 Ctrl + Alt + J 可以触发" }, {
  1227. default: vue.withCtx(() => [
  1228. vue.createVNode(_component_el_button, {
  1229. type: "primary",
  1230. text: "",
  1231. onClick: vue.unref(randomProblem),
  1232. size: tableButtonSize.value
  1233. }, {
  1234. default: vue.withCtx(() => [
  1235. vue.createTextVNode(" 随机题目 ")
  1236. ]),
  1237. _: 1
  1238. }, 8, ["onClick", "size"])
  1239. ]),
  1240. _: 1
  1241. })
  1242. ]),
  1243. _: 1
  1244. })
  1245. ]),
  1246. _: 1
  1247. }),
  1248. vue.createVNode(_component_el_table, {
  1249. data: vue.unref(urlsData),
  1250. height: "300",
  1251. style: { "width": "100%", "margin-top": "10px" }
  1252. }, {
  1253. default: vue.withCtx(() => [
  1254. vue.createVNode(_component_el_table_column, { type: "index" }),
  1255. vue.createVNode(_component_el_table_column, {
  1256. label: "标题",
  1257. width: "auto",
  1258. align: "center"
  1259. }, {
  1260. default: vue.withCtx((scope) => [
  1261. vue.createVNode(_component_el_link, {
  1262. href: scope.row.link,
  1263. target: "_blank",
  1264. type: "default"
  1265. }, {
  1266. default: vue.withCtx(() => [
  1267. vue.createTextVNode(vue.toDisplayString(scope.row.title), 1)
  1268. ]),
  1269. _: 2
  1270. }, 1032, ["href"])
  1271. ]),
  1272. _: 1
  1273. }),
  1274. vue.createVNode(_component_el_table_column, {
  1275. label: "随机",
  1276. width: "70",
  1277. align: "center"
  1278. }, {
  1279. default: vue.withCtx((scope) => [
  1280. vue.createVNode(_component_el_switch, {
  1281. modelValue: scope.row.select,
  1282. "onUpdate:modelValue": ($event) => scope.row.select = $event,
  1283. onChange: ($event) => selectHandlerChange(scope.row),
  1284. disabled: rowIsDisabled.value(scope.row),
  1285. size: "small"
  1286. }, null, 8, ["modelValue", "onUpdate:modelValue", "onChange", "disabled"])
  1287. ]),
  1288. _: 1
  1289. }),
  1290. vue.createVNode(_component_el_table_column, {
  1291. label: "AC",
  1292. width: "70",
  1293. align: "center"
  1294. }, {
  1295. default: vue.withCtx((scope) => [
  1296. vue.createVNode(_component_el_link, {
  1297. type: "success",
  1298. underline: false,
  1299. onClick: ($event) => showProblemsInfo(scope.row)
  1300. }, {
  1301. default: vue.withCtx(() => [
  1302. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.ac) ? 0 : scope.row.ac), 1)
  1303. ]),
  1304. _: 2
  1305. }, 1032, ["onClick"])
  1306. ]),
  1307. _: 1
  1308. }),
  1309. vue.createVNode(_component_el_table_column, {
  1310. label: "Total",
  1311. width: "70",
  1312. align: "center"
  1313. }, {
  1314. default: vue.withCtx((scope) => [
  1315. vue.createVNode(_component_el_link, {
  1316. type: "primary",
  1317. underline: false,
  1318. onClick: ($event) => showProblemsInfo(scope.row)
  1319. }, {
  1320. default: vue.withCtx(() => [
  1321. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.tot) ? 0 : scope.row.tot), 1)
  1322. ]),
  1323. _: 2
  1324. }, 1032, ["onClick"])
  1325. ]),
  1326. _: 1
  1327. }),
  1328. vue.createVNode(_component_el_table_column, {
  1329. label: "进度",
  1330. width: "70",
  1331. align: "center"
  1332. }, {
  1333. default: vue.withCtx((scope) => [
  1334. vue.createVNode(_component_el_link, {
  1335. onClick: ($event) => showProblemsInfo(scope.row),
  1336. type: "warning",
  1337. underline: false
  1338. }, {
  1339. default: vue.withCtx(() => {
  1340. var _a, _b, _c;
  1341. return [
  1342. 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)
  1343. ];
  1344. }),
  1345. _: 2
  1346. }, 1032, ["onClick"])
  1347. ]),
  1348. _: 1
  1349. }),
  1350. vue.createVNode(_component_el_table_column, {
  1351. label: "操作",
  1352. width: "200px",
  1353. align: "center"
  1354. }, {
  1355. default: vue.withCtx((scope) => [
  1356. vue.createVNode(_component_el_button, {
  1357. loading: scope.row.loading,
  1358. onClick: ($event) => asyncProblemStatus(scope.row),
  1359. size: "small",
  1360. type: "success",
  1361. disabled: rowIsDisabled.value(scope.row),
  1362. link: ""
  1363. }, {
  1364. default: vue.withCtx(() => [
  1365. vue.createTextVNode(vue.toDisplayString(scope.row.loading ? "" : "同步"), 1)
  1366. ]),
  1367. _: 2
  1368. }, 1032, ["loading", "onClick", "disabled"]),
  1369. vue.createVNode(_component_el_button, {
  1370. onClick: ($event) => handlerProblems("update", scope.row, scope.$index),
  1371. size: "small",
  1372. type: "primary",
  1373. disabled: rowIsDisabled.value(scope.row),
  1374. link: ""
  1375. }, {
  1376. default: vue.withCtx(() => [
  1377. vue.createTextVNode("编辑")
  1378. ]),
  1379. _: 2
  1380. }, 1032, ["onClick", "disabled"]),
  1381. vue.createVNode(_component_el_button, {
  1382. onClick: ($event) => deleteProblems(scope.row.id),
  1383. size: "small",
  1384. type: "danger",
  1385. link: "",
  1386. disabled: rowIsDisabled.value(scope.row)
  1387. }, {
  1388. default: vue.withCtx(() => [
  1389. vue.createTextVNode("删除")
  1390. ]),
  1391. _: 2
  1392. }, 1032, ["onClick", "disabled"])
  1393. ]),
  1394. _: 1
  1395. })
  1396. ]),
  1397. _: 1
  1398. }, 8, ["data"]),
  1399. vue.createVNode(_component_el_row, {
  1400. gutter: 10,
  1401. style: { "margin": "10px 0" }
  1402. }, {
  1403. default: vue.withCtx(() => [
  1404. vue.createVNode(_component_el_col, { span: 6 }, {
  1405. default: vue.withCtx(() => [
  1406. vue.createTextVNode(" 会员  "),
  1407. vue.createVNode(_component_el_tooltip, { content: "过滤会员题目,会员题不会出现在随机题目中,默认过滤" }, {
  1408. default: vue.withCtx(() => [
  1409. vue.createVNode(_component_el_switch, {
  1410. modelValue: fromData.visiableMember,
  1411. "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => fromData.visiableMember = $event)
  1412. }, null, 8, ["modelValue"])
  1413. ]),
  1414. _: 1
  1415. }),
  1416. vue.createTextVNode(" ac  "),
  1417. vue.createVNode(_component_el_tooltip, { content: "过滤AC的题目,AC题目出现在随机题目中,默认不过滤" }, {
  1418. default: vue.withCtx(() => [
  1419. vue.createVNode(_component_el_switch, {
  1420. modelValue: fromData.showAcConfig,
  1421. "onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => fromData.showAcConfig = $event)
  1422. }, null, 8, ["modelValue"])
  1423. ]),
  1424. _: 1
  1425. })
  1426. ]),
  1427. _: 1
  1428. }),
  1429. vue.createVNode(_component_el_col, { span: 10 }, {
  1430. default: vue.withCtx(() => [
  1431. vue.createTextVNode("   "),
  1432. vue.createVNode(_component_el_tooltip, { content: "随机题目将会随机在这个区间中的题目" }, {
  1433. default: vue.withCtx(() => [
  1434. vue.createVNode(_component_el_link, {
  1435. underline: false,
  1436. type: "primary"
  1437. }, {
  1438. default: vue.withCtx(() => [
  1439. vue.createTextVNode("分数区间")
  1440. ]),
  1441. _: 1
  1442. })
  1443. ]),
  1444. _: 1
  1445. }),
  1446. vue.createTextVNode("   "),
  1447. vue.createVNode(_component_el_input, {
  1448. modelValue: fromData.min,
  1449. "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => fromData.min = $event),
  1450. "aria-placeholder": "",
  1451. placeholder: " min ",
  1452. style: { "width": "60px" }
  1453. }, null, 8, ["modelValue"]),
  1454. vue.createTextVNode("- "),
  1455. vue.createVNode(_component_el_input, {
  1456. modelValue: fromData.max,
  1457. "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => fromData.max = $event),
  1458. "aria-placeholder": "",
  1459. placeholder: " max",
  1460. style: { "width": "60px" }
  1461. }, null, 8, ["modelValue"])
  1462. ]),
  1463. _: 1
  1464. }),
  1465. vue.createVNode(_component_el_col, { span: 8 }, {
  1466. default: vue.withCtx(() => [
  1467. vue.createVNode(_component_el_tooltip, { content: "重置题单" }, {
  1468. default: vue.withCtx(() => [
  1469. vue.createVNode(_component_el_button, {
  1470. plain: "",
  1471. onClick: handlerDefault,
  1472. size: tableButtonSize.value,
  1473. disabled: showProcess.value
  1474. }, {
  1475. default: vue.withCtx(() => [
  1476. vue.createTextVNode(" 默认 ")
  1477. ]),
  1478. _: 1
  1479. }, 8, ["size", "disabled"])
  1480. ]),
  1481. _: 1
  1482. }),
  1483. vue.createVNode(_component_el_button, {
  1484. plain: "",
  1485. onClick: _cache[14] || (_cache[14] = ($event) => q1.value = !q1.value),
  1486. size: tableButtonSize.value
  1487. }, {
  1488. default: vue.withCtx(() => [
  1489. vue.createTextVNode(" 使用说明 ")
  1490. ]),
  1491. _: 1
  1492. }, 8, ["size"])
  1493. ]),
  1494. _: 1
  1495. })
  1496. ]),
  1497. _: 1
  1498. })
  1499. ]),
  1500. _: 1
  1501. }, 8, ["modelValue", "title"]),
  1502. vue.createVNode(_component_el_dialog, {
  1503. modelValue: asyncVisableDialog.value,
  1504. "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => asyncVisableDialog.value = $event),
  1505. width: "35%"
  1506. }, {
  1507. default: vue.withCtx(() => [
  1508. vue.createElementVNode("p", null, [
  1509. vue.createVNode(_component_el_link, {
  1510. href: showProblemsProcessInfo.link,
  1511. type: "info",
  1512. underline: false
  1513. }, {
  1514. default: vue.withCtx(() => [
  1515. vue.createTextVNode(vue.toDisplayString(showProblemsProcessInfo.title), 1)
  1516. ]),
  1517. _: 1
  1518. }, 8, ["href"])
  1519. ]),
  1520. vue.createElementVNode("div", _hoisted_2, [
  1521. vue.createVNode(_component_el_progress, {
  1522. type: "circle",
  1523. percentage: computeProcess(showProblemsProcessInfo.ac, showProblemsProcessInfo.tot),
  1524. color: processColors
  1525. }, {
  1526. default: vue.withCtx(({ percentage }) => [
  1527. vue.createElementVNode("p", null, vue.toDisplayString(percentage) + "%", 1)
  1528. ]),
  1529. _: 1
  1530. }, 8, ["percentage"])
  1531. ]),
  1532. vue.createElementVNode("p", _hoisted_3, vue.toDisplayString(showProblemsProcessInfo.ac) + " / " + vue.toDisplayString(showProblemsProcessInfo.tot), 1)
  1533. ]),
  1534. _: 1
  1535. }, 8, ["modelValue"])
  1536. ]);
  1537. };
  1538. }
  1539. };
  1540. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-003e83a0"]]);
  1541. const cssLoader = (e) => {
  1542. const t = GM_getResourceText(e);
  1543. return GM_addStyle(t), t;
  1544. };
  1545. cssLoader("elementPlusCss");
  1546. const stopRankingKey = "__is_stop_rating_ranking__";
  1547. let conetstTimeId = null;
  1548. function run$1() {
  1549. const container = document.querySelector(".contest-question-info .list-group");
  1550. if (!container) return;
  1551. const ls = Array.from(container.querySelectorAll(".list-group-item .pull-right"));
  1552. for (let i = 0; i < 4; i++) {
  1553. if (i >= ls.length) {
  1554. break;
  1555. }
  1556. if (ls[i] instanceof HTMLElement) {
  1557. ls[i].textContent = "0";
  1558. }
  1559. }
  1560. window.clearInterval(conetstTimeId);
  1561. }
  1562. function startStopRanking() {
  1563. if (!isContest(window.location.href)) {
  1564. return;
  1565. }
  1566. const isNext = !!document.querySelector("#__next");
  1567. if (isNext) {
  1568. return;
  1569. }
  1570. const use = Cache$1.get(stopRankingKey);
  1571. if (use) {
  1572. conetstTimeId = setInterval(() => {
  1573. run$1();
  1574. }, 10);
  1575. }
  1576. _GM_registerMenuCommand(`${use ? "使用" : "关闭"} 排行榜`, () => {
  1577. Cache$1.set(stopRankingKey, !use);
  1578. window.location.reload();
  1579. }, { title: "对于不想看到排行榜的可以使用此功能 默认开启" });
  1580. }
  1581. const local_url = window.location.href;
  1582. let loadID = 0;
  1583. let submitCnt = 0;
  1584. function watchDom(dom2) {
  1585. if (!(dom2 instanceof HTMLElement)) {
  1586. return;
  1587. }
  1588. let m = new MutationObserver(() => {
  1589. if (submitCnt % 2 == 1) {
  1590. submitProblems(local_url);
  1591. }
  1592. submitCnt++;
  1593. });
  1594. m.observe(dom2, {
  1595. childList: true,
  1596. attributes: true
  1597. });
  1598. }
  1599. 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__"]);
  1600. let Container = null;
  1601. Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_button_is_none__"], true, Boolean.name);
  1602. const start = () => {
  1603. Container = document.createElement("div");
  1604. const body = document.querySelector("body");
  1605. body.append(Container);
  1606. Container.style.display = "block";
  1607. return Container;
  1608. };
  1609. let dom = start();
  1610. const VueApp = vue.createApp(App);
  1611. VueApp.use(ElementPlus).mount(dom);
  1612. if (isProblem() || isLeetCodeCircleUrl()) {
  1613. _GM_registerMenuCommand(`随机一道题 ☕`, randomProblem, { title: "随机一道题目,你可以通过ctrl+atl+j显示一道题目" });
  1614. _GM_registerMenuCommand(`${randomProblemKey() ? "关闭" : "启用"} 随机题目快捷键 ☕`, () => {
  1615. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_random_problems_key__"], !randomProblemKey());
  1616. window.location.reload();
  1617. }, { title: "该功能是随机一道题的快捷键,你可以通过ctrl+atl+j显示一道题目" });
  1618. if (randomProblemKey()) {
  1619. document.addEventListener("keydown", async function(event) {
  1620. if (event.ctrlKey && event.altKey && event.key === "j") {
  1621. randomProblem();
  1622. }
  1623. });
  1624. }
  1625. }
  1626. function run() {
  1627. loadID++;
  1628. if (isProblem(local_url) || isContest(local_url)) {
  1629. if (isProblem(local_url) && loadID == 1) {
  1630. submitProblems(local_url);
  1631. }
  1632. setTimeout(() => {
  1633. let submitbutton = null;
  1634. const isNext = !!document.querySelector("#__next");
  1635. if (isProblem(local_url) || isNext) {
  1636. submitbutton = document.querySelector("div [data-e2e-locator=console-submit-button]");
  1637. } else {
  1638. let buttons = Array.from(document.querySelectorAll(".question-detail-bottom .pull-right button"));
  1639. for (let i = buttons.length - 1; i >= 0; i--) {
  1640. if (buttons[i].textContent.indexOf("提交解答") != -1) {
  1641. submitbutton = buttons[i];
  1642. break;
  1643. }
  1644. }
  1645. }
  1646. if (submitbutton) {
  1647. submitbutton.addEventListener("click", () => {
  1648. submitProblems(local_url, 10 * 1e3);
  1649. });
  1650. watchDom(submitbutton);
  1651. } else if (loadID < 10) {
  1652. run();
  1653. }
  1654. }, 3e3);
  1655. } else if (isLeetCodeCircleUrl(local_url)) {
  1656. _GM_registerMenuCommand(`安装到${install_pos() ? "右侧" : "左侧"} 🎁`, () => {
  1657. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_insert_pos__"], install_pos());
  1658. window.location.reload();
  1659. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  1660. _GM_registerMenuCommand(`清空题目状态缓存 🚀`, () => {
  1661. Message("确认清空题目状态缓存", () => {
  1662. deleteAllACCountKeys();
  1663. window.location.reload();
  1664. });
  1665. }, { title: "如果题目状态出现问题,可以试试,一般情况下不建议使用" });
  1666. _GM_registerMenuCommand(`同步题目状态 🚀`, () => {
  1667. Message("确认同步题目状态", async () => {
  1668. await addProcess(true, void 0, true);
  1669. });
  1670. }, { title: "如果不在同一个浏览器答题,会出现ac题目状态没有及时同步,可以使用此功能" });
  1671. _GM_registerMenuCommand(`${initObj().onlyUrls ? "仅在收藏题单页面生效" : "所有题单生效"}`, () => {
  1672. const u = initObj();
  1673. u.onlyUrls = !u.onlyUrls;
  1674. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"], u);
  1675. }, { title: "插件默认会在所有讨论发布页生效,如果只想在收藏链接生效,可以使用此功能" });
  1676. _GM_registerMenuCommand(`添加本页`, () => {
  1677. const urls = initUrls();
  1678. let ok = false;
  1679. let url = window.location.href;
  1680. for (let info of urls) {
  1681. if (!info || !(info == null ? void 0 : info.link)) {
  1682. continue;
  1683. }
  1684. if (info.link.indexOf(url) != -1) {
  1685. ok = true;
  1686. break;
  1687. }
  1688. }
  1689. if (ok) {
  1690. ElementPlus.ElMessage({
  1691. message: "收藏失败,链接已经存在!",
  1692. type: "error"
  1693. });
  1694. } else {
  1695. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  1696. try {
  1697. url = url.split("view")[0];
  1698. } catch (e) {
  1699. url = window.location.href;
  1700. }
  1701. }
  1702. urls.unshift({
  1703. title: document.title,
  1704. link: url
  1705. });
  1706. Container.style.display = "block";
  1707. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], urls);
  1708. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true);
  1709. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"], true);
  1710. ElementPlus.ElMessage({
  1711. message: "收藏成功!刷新生效",
  1712. type: "success"
  1713. });
  1714. }
  1715. });
  1716. }
  1717. }
  1718. run();
  1719. startStopRanking();
  1720.  
  1721. })(Vue, ElementPlus);