0x3f-problem-solution

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

当前为 2025-02-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 0x3f-problem-solution
  3. // @namespace https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution
  4. // @version 0.0.5.4
  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://greasyfork.org/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/*/problems/*
  14. // @match https://leetcode.com/circle/discuss/*
  15. // @match https://leetcode.com/discuss/*
  16. // @match https://leetcode.com/problems/*
  17. // @match https://leetcode.com/contest/*/problems/*
  18. // @require https://unpkg.com/vue@3.4.31/dist/vue.global.prod.js
  19. // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B
  20. // @require https://unpkg.com/element-plus@2.7.6/dist/index.full.js
  21. // @resource elementPlusCss https://unpkg.com/element-plus@2.7.6/dist/index.css
  22. // @grant GM_addStyle
  23. // @grant GM_deleteValue
  24. // @grant GM_getResourceText
  25. // @grant GM_getValue
  26. // @grant GM_registerMenuCommand
  27. // @grant GM_setValue
  28. // ==/UserScript==
  29.  
  30. (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const n=document.createElement("style");n.textContent=t,document.head.append(n)})(" h2[data-v-d1230ce3]{color:#000!important;margin:10px 0!important;font-size:20px!important}.m-setting-button[data-v-76dd1ba0]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-76dd1ba0]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-76dd1ba0]{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} ");
  31.  
  32. (function (ElementPlus, vue) {
  33. 'use strict';
  34.  
  35. var _GM_deleteValue = /* @__PURE__ */ (() => typeof GM_deleteValue != "undefined" ? GM_deleteValue : void 0)();
  36. var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
  37. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  38. var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
  39. let Cache$1 = class Cache2 {
  40. set(k, v) {
  41. _GM_setValue(k, v);
  42. }
  43. get(k, parse = true, name = String.name) {
  44. try {
  45. let v = _GM_getValue(k);
  46. switch (name) {
  47. case String.name:
  48. if (v == null) {
  49. return "null";
  50. }
  51. return v;
  52. case Object.name:
  53. if (v == null || v == void 0 || typeof v != "object") {
  54. return {};
  55. }
  56. return v;
  57. case Boolean.name:
  58. if (v === null || v == void 0) {
  59. return false;
  60. }
  61. if (v == false || v == "false" || v == "" || v == "null") {
  62. return false;
  63. }
  64. return v;
  65. case Array.name:
  66. if (v === null || v == void 0 || !Array.isArray(v)) {
  67. return [];
  68. }
  69. return v;
  70. default:
  71. return v;
  72. }
  73. } catch (E) {
  74. return null;
  75. }
  76. }
  77. remove(k) {
  78. _GM_deleteValue(k);
  79. }
  80. };
  81. const Cache$2 = new Cache$1();
  82. const width = 14;
  83. const height = 14;
  84. const bilibiliSVG = () => {
  85. return `<svg width="${width}px" height="${height}px" status="bilibili" title="bilibili" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#00a3d9">
  86. <path fill="none" d="M0 0h24v24H0z"></path>
  87. <path d="M18.223 3.086a1.25 1.25 0 0 1 0 1.768L17.08 5.996h1.17A3.75 3.75 0 0 1 22 9.747v7.5a3.75 3.75 0 0 1-3.75 3.75H5.75A3.75 3.75 0 0 1 2 17.247v-7.5a3.75 3.75 0 0 1 3.75-3.75h1.166L5.775 4.855a1.25 1.25 0 1 1 1.767-1.768l2.652 2.652q.119.119.198.257h3.213q.08-.14.199-.258l2.651-2.652a1.25 1.25 0 0 1 1.768 0m.027 5.42H5.75a1.25 1.25 0 0 0-1.247 1.157l-.003.094v7.5c0 .659.51 1.199 1.157 1.246l.093.004h12.5a1.25 1.25 0 0 0 1.247-1.157l.003-.093v-7.5c0-.69-.56-1.25-1.25-1.25zm-10 2.5c.69 0 1.25.56 1.25 1.25v1.25a1.25 1.25 0 1 1-2.5 0v-1.25c0-.69.56-1.25 1.25-1.25m7.5 0c.69 0 1.25.56 1.25 1.25v1.25a1.25 1.25 0 1 1-2.5 0v-1.25c0-.69.56-1.25 1.25-1.25"></path>
  88. </svg>
  89. `;
  90. };
  91. const problemContenst = () => `
  92. <svg width="${width}px" height="${height}px" status="contest" title="竞赛题目专属图标" viewBox="-3.5 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
  93. <path d="M9.73795 18.8436L12.9511 20.6987L6.42625 32L4.55349 27.8233L9.73795 18.8436Z" fill="#CE4444"/>
  94. <path d="M9.73795 18.8436L6.52483 16.9885L0 28.2898L4.55349 27.8233L9.73795 18.8436Z" fill="#983535"/>
  95. <path d="M14.322 18.8436L11.1088 20.6987L17.6337 32L19.5064 27.8233L14.322 18.8436Z" fill="#983535"/>
  96. <path d="M14.322 18.8436L17.5351 16.9885L24.0599 28.2898L19.5064 27.8233L14.322 18.8436Z" fill="#CE4444"/>
  97. <path d="M22.9936 11.0622C22.9936 17.1716 18.0409 22.1243 11.9314 22.1243C5.82194 22.1243 0.869249 17.1716 0.869249 11.0622C0.869249 4.9527 5.82194 0 11.9314 0C18.0409 0 22.9936 4.9527 22.9936 11.0622Z" fill="url(#paint0_linear_103_1801)"/>
  98. <path d="M20.5665 11.0621C20.5665 15.8311 16.7004 19.6972 11.9315 19.6972C7.16247 19.6972 3.29645 15.8311 3.29645 11.0621C3.29645 6.29315 7.16247 2.42713 11.9315 2.42713C16.7004 2.42713 20.5665 6.29315 20.5665 11.0621Z" fill="#A88300"/>
  99. <path d="M21.0477 11.984C21.0477 16.7641 17.1727 20.6391 12.3926 20.6391C7.61251 20.6391 3.73748 16.7641 3.73748 11.984C3.73748 7.20389 7.61251 3.32887 12.3926 3.32887C17.1727 3.32887 21.0477 7.20389 21.0477 11.984Z" fill="#C28B37"/>
  100. <path d="M20.5868 11.0621C20.5868 15.8422 16.7118 19.7172 11.9317 19.7172C7.15159 19.7172 3.27656 15.8422 3.27656 11.0621C3.27656 6.28205 7.15159 2.40702 11.9317 2.40702C16.7118 2.40702 20.5868 6.28205 20.5868 11.0621Z" fill="#C09525"/>
  101. <path d="M11.9781 5.04096L13.8451 8.77502L17.5792 9.24178L15.0151 12.117L15.7122 16.2431L11.9781 14.3761L8.24404 16.2431L8.94729 12.117L6.37701 9.24178L10.1111 8.77502L11.9781 5.04096Z" fill="url(#paint1_linear_103_1801)"/>
  102. <defs>
  103. <linearGradient id="paint0_linear_103_1801" x1="11.1804" y1="4.03192" x2="12.6813" y2="31.965" gradientUnits="userSpaceOnUse">
  104. <stop stop-color="#FFC600"/>
  105. <stop offset="1" stop-color="#FFDE69"/>
  106. </linearGradient>
  107. <linearGradient id="paint1_linear_103_1801" x1="11.9783" y1="5.04096" x2="11.9783" y2="16.2431" gradientUnits="userSpaceOnUse">
  108. <stop stop-color="#FFFCDD"/>
  109. <stop offset="1" stop-color="#FFE896"/>
  110. </linearGradient>
  111. </defs>
  112. </svg>
  113.  
  114. `;
  115. const problemFinsh = () => `
  116.  
  117. <svg width="${width}px" height="${height}px" status="ac" title="AC专属图标" viewBox="0 0 1024 1024" version="1.1"
  118. xmlns="http://www.w3.org/2000/svg">
  119. <path d="M512 512m-448 0a448 448 0 1 0 896 0 448 448 0 1 0-896 0Z" fill="#4CAF50" />
  120. <path
  121. d="M738.133333 311.466667L448 601.6l-119.466667-119.466667-59.733333 59.733334 179.2 179.2 349.866667-349.866667z"
  122. fill="#CCFF90" />
  123. </svg>
  124.  
  125. `;
  126. const problemsTry = () => `
  127. <svg width="${width}px" height="${height}px" status="notac" title="尝试过" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
  128. xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512"
  129. style="enable-background:new 0 0 512 512;" xml:space="preserve">
  130. <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
  131. S390.101,12.8,256,12.8z" />
  132. <g>
  133. <path style="fill:#573A32;" d="M256,115.2c-49.271,0-92.561,25.353-117.726,63.676l18.859,18.859
  134. 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
  135. C396.8,178.244,333.764,115.2,256,115.2z" />
  136. <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
  137. 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" />
  138. <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
  139. 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
  140. C334.822,348.194,298.266,371.2,256,371.2z" />
  141. </g>
  142. </svg>
  143.  
  144. `;
  145. const problemsNo = () => install_pos() ? `
  146. <svg width="${width}px" height="${height}px" status="null" title="未尝试" 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>
  147. ` : ``;
  148. const createStatus = (status, link) => {
  149. var _a;
  150. let node;
  151. if (!link) {
  152. return;
  153. }
  154. const curUrl = (link == null ? void 0 : link.href) ?? ((_a = link.querySelector("a")) == null ? void 0 : _a.href);
  155. node = link instanceof HTMLAnchorElement ? link.parentElement : link;
  156. if (node) {
  157. node.status = status;
  158. }
  159. let installSVG = "";
  160. if (isContest(curUrl)) {
  161. installSVG = problemContenst();
  162. } else if (isLeetCodeCircleUrl(curUrl)) ;
  163. else if (isBilibili(curUrl)) {
  164. installSVG = bilibiliSVG();
  165. } else {
  166. if (status == STATUS["AC"]) {
  167. installSVG = problemFinsh();
  168. } else if (status == STATUS["notac"]) {
  169. installSVG = problemsTry();
  170. } else if (status == STATUS["NO"]) {
  171. installSVG = problemsNo();
  172. }
  173. }
  174. let svg = node.querySelector("svg");
  175. if (svg) {
  176. if (svg.getAttribute("status") == status || svg.getAttribute("status") == STATUS["AC"]) {
  177. return false;
  178. }
  179. svg.remove();
  180. }
  181. if (isBilibili(curUrl)) {
  182. node.innerHTML = node.innerHTML + "&nbsp;" + installSVG;
  183. } else {
  184. node.innerHTML = install_pos() ? installSVG + node.innerHTML : node.innerHTML + installSVG;
  185. }
  186. return true;
  187. };
  188. const inf = 4e3;
  189. const mi = 1e3;
  190. const __0X3F_PROBLEM_KEYS__$1 = {
  191. "__0x3f_problmes_solution__": "__0x3f_problmes_solution__",
  192. // 基本信息
  193. "__0x3f_problmes_urls__": "__0x3f_problmes_urls__",
  194. // 题单key
  195. "__0x3f_problmes_update__": "__0x3f_problmes_update__",
  196. // 是否修改了默认题单key
  197. "__0x3f_problmes_button_is_none__": "__is_none_0x3f_problmes_button__",
  198. // 是否隐藏设置按钮
  199. "__0x3f_problmes_insert_pos__": "__0x3f_problmes_insert_pos__",
  200. // 安装位置
  201. "__0x3f_problmes_status_update__": "__0x3f_problmes_status_update__",
  202. "__0x3f_problmes_plugin_load_ok__": "__0x3f_problmes_plugin_load_ok__",
  203. // 是否使用插件
  204. "__0x3f_problmes_add_cur__": "__0x3f_problmes_add_cur__",
  205. // 添加 url
  206. "__0x3f_problmes_ac_key__": "__local_ok_problem_key__",
  207. // ac key
  208. "__0x3f_problmes_ac_version__": "__0x3f_problmes_ac_version__",
  209. // TODO ac key version
  210. "__0x3f_problmes_all_problems__": "__0x3f_problmes_all_problems__",
  211. // all problems
  212. "__0x3f_problmes_random_problems_key__": "__0x3f_problmes_random_problems_key__",
  213. //随机题目快捷键
  214. "__0x3f_problmes_random_problems__": "__0x3f_problmes_random_problems__",
  215. //随机题目
  216. "__0x3f_problme_support_type__": "__0x3f_problme_support_type__",
  217. //是否替换到com 默认cn
  218. "__0x3f_problme_support_type_tips__": "__0x3f_problme_support_type_tips__"
  219. //是否替换到com 默认cn 不再提示key
  220. };
  221. const STATUS = {
  222. "AC": "ac",
  223. "NO": "null",
  224. "notac": "notac",
  225. "Accepted": "ac",
  226. "Wrong Answer": "notac"
  227. };
  228. const defaultObj = {
  229. min: mi,
  230. max: inf,
  231. visiableMember: true,
  232. onlyUrls: false,
  233. useDefaultSetting: true,
  234. hiddenAc: false,
  235. showAcConfig: true,
  236. sortedType: 0
  237. };
  238. function install_pos() {
  239. return !Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_insert_pos__"], false, Boolean.name);
  240. }
  241. function isShow(text, min, max) {
  242. if (!text) {
  243. return true;
  244. }
  245. let res = text.match(/\d+/ig);
  246. if (!res) {
  247. return true;
  248. }
  249. if (Array.isArray(res) && res.length < 2) {
  250. return true;
  251. }
  252. let s = 0;
  253. for (let i = res.length - 1; i >= 0; i--) {
  254. s = res[i];
  255. if (s >= mi && s <= inf) {
  256. return s >= min && s <= max;
  257. }
  258. }
  259. return true;
  260. }
  261. let A = void 0;
  262. const linkCssSelector_pre = () => isEnglishENV() ? ".discuss-markdown-container" : `#lc-content [class*="CollapsibleMarkdownContent"] [class*="MarkdownContent"]`;
  263. const linkCssSelector = `${linkCssSelector_pre()} li>a`;
  264. const queryProblem = () => Array.from(document.querySelectorAll(linkCssSelector)).filter((item) => item && item instanceof HTMLAnchorElement && (isProblem(item.href) || isContest(item.href)));
  265. function loadProblems() {
  266. A = queryProblem();
  267. return A;
  268. }
  269. function handlerProblem(data) {
  270. var _a;
  271. try {
  272. loadProblems();
  273. let { min, max, visiableMember, useDefaultSetting, onlyUrls, hiddenAc } = data;
  274. if (isNaN(min) || isNaN(max)) {
  275. min = mi;
  276. max = inf;
  277. }
  278. if (min < mi) {
  279. min = mi;
  280. }
  281. if (max < min) {
  282. max = inf;
  283. }
  284. min = Number(min);
  285. max = Number(max);
  286. data.min = min;
  287. data.max = max;
  288. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"], data);
  289. for (let i = 0; i < A.length; i++) {
  290. if (!(A[i] instanceof HTMLAnchorElement)) {
  291. continue;
  292. }
  293. let d = (_a = A[i]) == null ? void 0 : _a.parentNode;
  294. if (!d) {
  295. continue;
  296. }
  297. let none = false;
  298. let Nohidden = isShow(d.textContent, min, max);
  299. d.style.display = Nohidden ? "" : "none";
  300. if (!Nohidden) {
  301. continue;
  302. }
  303. if (hiddenAc) {
  304. const svg = d.querySelector("svg");
  305. if (svg && svg.getAttribute("status")) {
  306. d.style.display = svg.getAttribute("status") == STATUS["AC"] ? "none" : "";
  307. }
  308. } else {
  309. d.style.display = "";
  310. }
  311. let c = d.textContent && d.textContent.indexOf("会员") != -1;
  312. if (!c) {
  313. continue;
  314. }
  315. d.style.display = visiableMember ? "" : "none";
  316. }
  317. } catch (e) {
  318. console.log("error", e);
  319. }
  320. }
  321. function computeAcInfo(saveUrls = [], deleteOk = true) {
  322. let infos = [];
  323. let set = /* @__PURE__ */ new Set();
  324. for (let i = 0, u = null; Array.isArray(saveUrls) && i < saveUrls.length; i++) {
  325. try {
  326. u = saveUrls[i];
  327. if (!(u == null ? void 0 : u.link) || !(u == null ? void 0 : u.title) || !(u == null ? void 0 : u.id) || set.has(u.link)) {
  328. continue;
  329. }
  330. if (u["select"] == void 0) u.select = true;
  331. if (u["loading"] == void 0 || u["loading"]) u["loading"] = false;
  332. let s = Object.values(u).join("");
  333. if (s == "null" || !Cache$2.get(u.link) || !getAcCountKey(u.link) || !Cache$2.get(getAcCountKey(u.link))) {
  334. continue;
  335. }
  336. let o = Cache$2.get(getAcCountKey(u.link));
  337. u["ac"] = isNaN(o["ac"]) ? 0 : parseInt(o["ac"]);
  338. u["tot"] = isNaN(o["tot"]) ? 0 : parseInt(o["tot"]);
  339. set.add(u.link);
  340. } catch (e) {
  341. }
  342. infos.push(Object.assign({}, u));
  343. }
  344. if (deleteOk) {
  345. for (let i = 0; i < saveUrls[i]; i++) {
  346. delete saveUrls[i];
  347. }
  348. for (let info of infos) {
  349. saveUrls.push(info);
  350. }
  351. }
  352. return infos;
  353. }
  354. const initUrls = () => {
  355. let saveUrls = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_update__"], true, Boolean.name) ? Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], true, Array.name) : defaultUrls;
  356. return computeAcInfo(saveUrls);
  357. };
  358. const initObj = () => {
  359. let obj = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"]) ? Object.assign(defaultObj, Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"])) : defaultObj;
  360. if (obj["showAcConfig"] == null || obj["showAcConfig"] == void 0) {
  361. obj.showAcConfig = true;
  362. }
  363. if (obj["sortedType"] == null || obj["sortedType"] == void 0) {
  364. obj.sortedType = 0;
  365. }
  366. let temp = {};
  367. for (let key of Object.keys(obj)) {
  368. if (!isNaN(key) || defaultObj[`${key}`] == void 0) continue;
  369. temp[`${key}`] = obj[`${key}`];
  370. }
  371. return temp;
  372. };
  373. const support_plugins = () => {
  374. const u = initObj();
  375. if (!u || !u.onlyUrls) return true;
  376. let url = window.location.href;
  377. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  378. try {
  379. url = url.split("view")[0];
  380. } catch (e) {
  381. url = window.location.href;
  382. }
  383. }
  384. const urls = initUrls();
  385. for (let info of urls) {
  386. if (!info || !(info == null ? void 0 : info.link)) {
  387. continue;
  388. }
  389. if (info.link.indexOf(url) != -1) {
  390. return true;
  391. }
  392. }
  393. return false;
  394. };
  395. const defaultUrls = [
  396. { "title": "数学算法(数论/组合/概率期望/博弈/计算几何/随机算法", "link": "https://leetcode.cn/circle/discuss/IYT3ss/", "tot": 0, "ac": 0, "id": 1, "disabled": false, "select": true },
  397. { "title": "常用数据结构(前缀和/差分/栈/队列/堆/字典树/并查集/树状数组/线段树)", "link": "https://leetcode.cn/circle/discuss/mOr1u6/", "tot": 0, "ac": 0, "id": 2, "disabled": false, "select": true },
  398. { "title": "动态规划(入门/背包/状态机/划分/区间/状压/数位/树形/数据结构优化)", "link": "https://leetcode.cn/circle/discuss/tXLS3i/", "tot": 0, "ac": 0, "id": 3, "disabled": false, "select": true },
  399. { "title": "图论算法(DFS/BFS/拓扑排序/最短路/最小生成树/二分图/基环树/欧拉路径)", "link": "https://leetcode.cn/circle/discuss/01LUak/", "tot": 0, "ac": 0, "id": 4, "disabled": false, "select": true },
  400. { "title": "位运算(基础/性质/拆位/试填/恒等式/贪心/脑筋急转弯)", "link": "https://leetcode.cn/circle/discuss/dHn9Vk/", "tot": 0, "ac": 0, "id": 5, "disabled": false, "select": true },
  401. { "title": "网格图(DFS/BFS/综合应用)", "link": "https://leetcode.cn/circle/discuss/YiXPXW/", "tot": 0, "ac": 0, "id": 6, "disabled": false, "select": true },
  402. { "title": "单调栈(矩形面积/贡献法/最小字典序", "link": "https://leetcode.cn/circle/discuss/9oZFK9/", "tot": 0, "ac": 0, "id": 7, "disabled": false, "select": true },
  403. { "title": "二分算法(二分答案/最小化最大值/最大化最小值/第K小", "link": "https://leetcode.cn/circle/discuss/SqopEo/", "tot": 0, "ac": 0, "id": 8, "disabled": true, "select": true },
  404. { "title": "滑动窗口(定长/不定长/多指针", "link": "https://leetcode.cn/circle/discuss/0viNMK/", "tot": 0, "ac": 0, "id": 9, "disabled": false, "select": true },
  405. { "title": "贪心算法(基本贪心策略/反悔/区间/字典序/数学/思维/构造)", "link": "https://leetcode.cn/circle/discuss/g6KTKL/", "tot": 0, "ac": 0, "id": 10, "disabled": false, "select": true },
  406. { "title": "链表、二叉树与一般树(前后指针/快慢指针/DFS/BFS/直径/LCA)", "link": "https://leetcode.cn/circle/discuss/K0n2gO/", "tot": 0, "ac": 0, "id": 11, "disabled": false, "select": true },
  407. { "title": "字符串(KMP/Z函数/Manacher/字符串哈希/AC自动机/后缀数组/子序列自动机)", "link": "https://leetcode.cn/circle/discuss/SJFwQI/", "tot": 0, "ac": 0, "id": 12, "disabled": false, "select": true }
  408. // { 'title': '灵茶题单完成情况', 'link': 'https://leetcode.cn/u/endlesscheng/', 'tot': 0, 'ac': 0, 'id': 0x3f3f3f3f,'disabled':true,'select':false },
  409. ];
  410. function getId(problemUrl) {
  411. if (isContest(problemUrl) || isProblem(problemUrl)) {
  412. try {
  413. return problemUrl.split("problems")[1].split("/")[1];
  414. } catch (e) {
  415. return "";
  416. }
  417. }
  418. return "";
  419. }
  420. function postData(ID2) {
  421. return {
  422. "query": "\n query userQuestionStatus($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n status\n }\n}\n ",
  423. "variables": {
  424. "titleSlug": ID2
  425. },
  426. "operationName": "userQuestionStatus"
  427. };
  428. }
  429. async function queryStatus(ID2 = "", cache = {}, cur = void 0, watch2 = false) {
  430. var _a, _b, _c;
  431. if (!ID2) {
  432. return;
  433. }
  434. if (cache[ID2] == void 0 || cache[ID2] != STATUS["AC"]) {
  435. const response = await getProblemAcInfo(ID2);
  436. if (isDev()) {
  437. console.log("query result response:", response);
  438. }
  439. if ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.question) {
  440. const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status;
  441. if (cache[ID2] == void 0 || cache[ID2] != status) {
  442. cache[ID2] = status == null ? "null" : status;
  443. if (watch2) {
  444. if (isDev()) {
  445. console.log("save local status :", cache[ID2], "status = ", status, "get local status :", Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"])[ID2]);
  446. }
  447. watchSaveStatus(ID2, cache[ID2]);
  448. }
  449. createStatus(cache[ID2], cur);
  450. }
  451. } else {
  452. console.warn("query result is undefined");
  453. createStatus(cache[ID2], cur);
  454. }
  455. }
  456. }
  457. async function addProcess(reload = true, doms = void 0, asyncAc = false) {
  458. var _a;
  459. let problems_doms = Array.isArray(doms) ? doms : loadProblems();
  460. const cache = getLocalProblemStatus();
  461. let uid = 0, query_cnt = 0;
  462. const isReplaceEnglish = isEnglish();
  463. for (let i = 0; i < problems_doms.length; i++) {
  464. let cur = problems_doms[i].parentElement;
  465. if (!(cur instanceof HTMLElement)) {
  466. continue;
  467. }
  468. const ID2 = getId((_a = problems_doms[i]) == null ? void 0 : _a.href);
  469. if (!ID2) {
  470. continue;
  471. }
  472. if (install_pos()) {
  473. cur.style.listStyleType = "none";
  474. }
  475. if (isReplaceEnglish && problems_doms[i].href) {
  476. problems_doms[i].href = problems_doms[i].href.replace("leetcode.cn", "leetcode.com");
  477. }
  478. if (!cache[ID2] || cache[ID2] != STATUS["AC"] && asyncAc) {
  479. await sleep(50);
  480. await queryStatus(ID2, cache, cur, false);
  481. query_cnt++;
  482. if (query_cnt % 10 == 0) {
  483. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], cache);
  484. }
  485. } else {
  486. let status = cache[ID2];
  487. uid++;
  488. createStatus(status, cur);
  489. }
  490. }
  491. if (isDev()) {
  492. console.log("cache num :", uid, ",tot:", A.length);
  493. }
  494. getProcess();
  495. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], cache);
  496. let other = Array.from(document.querySelectorAll(`${linkCssSelector_pre()} p>a`)).filter((item) => item && item instanceof HTMLAnchorElement && isBilibili(item.href));
  497. for (let i = 0; i < other.length; i++) {
  498. createStatus("null", other[i]);
  499. }
  500. }
  501. const submitProblems = (url = window.location.href, timeout = 500) => {
  502. const ID2 = getId(url);
  503. if (!ID2) {
  504. return;
  505. }
  506. setTimeout(() => {
  507. const cache = getLocalProblemStatus();
  508. console.log("ID:", ID2, "query status: ", cache[ID2]);
  509. queryStatus(ID2, cache, void 0, true);
  510. }, timeout);
  511. };
  512. const watchSaveStatus = (ID2, status) => {
  513. const cache = getLocalProblemStatus();
  514. if (cache[ID2] != "ac") {
  515. cache[ID2] = status;
  516. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], cache);
  517. window.localStorage.setItem(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_status_update__"], JSON.stringify({
  518. "id": ID2,
  519. "status": status
  520. }));
  521. }
  522. };
  523. const watchLinkStatusUpdate = (e) => {
  524. var _a;
  525. if (e.key != __0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_status_update__"]) {
  526. return;
  527. }
  528. let { id, status } = JSON.parse(e.newValue);
  529. if (!id || !status) {
  530. return;
  531. }
  532. let thisLink = `${CUR_URL}/problems/${id}`;
  533. if (isDev()) {
  534. console.log("update", thisLink, "status", status);
  535. }
  536. let link = document.querySelector(`${linkCssSelector}[href^="${CUR_URL}/problems/${id}"]`);
  537. if (!link || !(link == null ? void 0 : link.parentElement)) {
  538. let doms = loadProblems();
  539. for (let i = 0; i < doms.length; i++) {
  540. if (!doms[i] || !((_a = doms[i]) == null ? void 0 : _a.parentElement)) {
  541. continue;
  542. }
  543. if (doms[i].href.indexOf(thisLink) != -1) {
  544. link = doms[i];
  545. break;
  546. }
  547. }
  548. }
  549. createStatus(status, link);
  550. };
  551. function getAcCountKey(k) {
  552. if (!k) return "";
  553. return `0x3f_ac_key_${k}`;
  554. }
  555. function deleteAllACCountKeys() {
  556. let urls = initUrls();
  557. let keys = [];
  558. for (let urlInfo of urls) {
  559. let key = getAcCountKey(urlInfo.link);
  560. Cache$2.remove(key);
  561. keys.push(key);
  562. }
  563. Cache$2.remove(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"]);
  564. return keys;
  565. }
  566. async function getProcess() {
  567. var _a;
  568. loadProblems();
  569. const cache = getLocalProblemStatus();
  570. const config = initObj();
  571. const response = await githubProblem(true);
  572. const mapInfo = response[1];
  573. let cnt = 0;
  574. let tot = 0;
  575. for (let i = 0; i < A.length; i++) {
  576. let ID2 = getId(A[i].href);
  577. if (!(config == null ? void 0 : config.visiableMember) && ((_a = mapInfo.get(ID2)) == null ? void 0 : _a.member)) {
  578. continue;
  579. }
  580. if (ID2 && cache[ID2] == STATUS["AC"]) {
  581. cnt++;
  582. }
  583. tot++;
  584. }
  585. let url = window.location.href;
  586. if (A.length > 0 && getAcCountKey(url)) {
  587. Cache$2.set(getAcCountKey(url), { "tot": tot, "ac": cnt });
  588. }
  589. return [cnt, tot];
  590. }
  591. function getLocalProblemStatus() {
  592. return Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name);
  593. }
  594. function getRandomInfo(array) {
  595. if (!Array.isArray(array)) return void 0;
  596. return array[Math.floor(Math.random() * array.length)];
  597. }
  598. function isEnglish() {
  599. return Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type__"], Boolean.name) == true;
  600. }
  601. function changeEnglishType() {
  602. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type__"], !isEnglish());
  603. if (Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"], String.name) != "NO") {
  604. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"], "OK");
  605. }
  606. window.location.reload();
  607. }
  608. function installEnglishLinkChangeCommand() {
  609. if (!isLeetCodeCircleUrl() || isEnglishENV()) {
  610. return;
  611. }
  612. _GM_registerMenuCommand(`题目链接切换到${isEnglish() ? "国服🎈" : "美服🌎"}`, () => {
  613. changeEnglishType();
  614. }, { title: "将题单链接替换为国服或者替换为美服" });
  615. }
  616. async function githubProblem(not_filter_member = true) {
  617. let allProbmems;
  618. if (!Array.isArray(allProbmems) || allProbmems.length == 0) {
  619. let response = await getProblemsJSON();
  620. if (Array.isArray(response)) {
  621. allProbmems = [...response];
  622. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_all_problems__"], [...response]);
  623. }
  624. } else {
  625. allProbmems = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_all_problems__"], true, Array.name);
  626. }
  627. if (!Array.isArray(allProbmems)) {
  628. ElementPlus.ElMessage({
  629. type: "error",
  630. message: "随机题目失败获取不到任何信息 !请如果出现这种情况,请前往 https://github.com/wuxin0011/tampermonkey-script/issues 反馈",
  631. duration: 6e3
  632. });
  633. return;
  634. }
  635. let config = initObj();
  636. let urlsData = initUrls();
  637. let set = /* @__PURE__ */ new Set();
  638. for (let info of urlsData) {
  639. if (info.link && info.select) {
  640. set.add(info.link);
  641. }
  642. }
  643. let acMap = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name);
  644. if (isDev()) {
  645. console.log("config and set", config, set);
  646. console.log("acMap", acMap);
  647. }
  648. let infos = [];
  649. let mapInfo = /* @__PURE__ */ new Map();
  650. let totInfo = [];
  651. for (let info of allProbmems) {
  652. if (!(info == null ? void 0 : info.problemUrl) || !set.has(info == null ? void 0 : info.problemUrl) || !Array.isArray(info.problems) || info.problems.length == 0) {
  653. continue;
  654. }
  655. let cur_infos = [];
  656. for (let i = 0; Array.isArray(info.problems) && i < info.problems.length; i++) {
  657. try {
  658. let { title, url, member, score, titleSlug } = info.problems[i];
  659. if (!url || !title) continue;
  660. if (!(config == null ? void 0 : config.visiableMember) && member || !not_filter_member && member) {
  661. continue;
  662. }
  663. let new_obj = { title, url, member, score, titleSlug, "status": acMap[titleSlug] };
  664. infos.push(new_obj);
  665. cur_infos.push(new_obj);
  666. mapInfo.set(titleSlug, new_obj);
  667. } catch (e) {
  668. console.log("error", e);
  669. }
  670. }
  671. info.problems = cur_infos;
  672. totInfo.push(info);
  673. }
  674. return [infos, mapInfo, totInfo];
  675. }
  676. async function randomProblem() {
  677. let responseDatas = await githubProblem();
  678. let acMap = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name);
  679. let config = initObj();
  680. let problems = responseDatas[0];
  681. let infos = [];
  682. for (let i = 0; Array.isArray(problems) && i < problems.length; i++) {
  683. try {
  684. let { title, url, member, score, titleSlug } = problems[i];
  685. if (!url || !title) continue;
  686. if (isDev()) {
  687. }
  688. if (!(config == null ? void 0 : config.showAcConfig) && acMap[titleSlug] == "ac") {
  689. continue;
  690. }
  691. if (!(config == null ? void 0 : config.visiableMember) && member) {
  692. continue;
  693. }
  694. if (score != 0 && (score < (config == null ? void 0 : config.min) || score > (config == null ? void 0 : config.max))) {
  695. continue;
  696. }
  697. infos.push({ title, url, member, score, titleSlug, "status": acMap[titleSlug] });
  698. } catch (e) {
  699. console.log("error", e);
  700. }
  701. }
  702. let data = getRandomInfo(infos);
  703. if (data.url && isEnglish()) {
  704. data.url = data.url.replace(ZH_URL, EN_URL);
  705. }
  706. ElementPlus.ElMessage({
  707. dangerouslyUseHTMLString: !!(data && (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title)),
  708. type: (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title) ? "success" : "error",
  709. 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>` : `没有符合条件的题目,请重新配置条件!`,
  710. duration: 6e3
  711. });
  712. }
  713. function isEnglishENV() {
  714. return window.location.href.indexOf("https://leetcode.com") != -1;
  715. }
  716. const isHttp = (url) => /^https?:\/\/.*$/.test(url);
  717. const isLeetCodeCircleUrl = (url = window.location.href) => /^https?:\/\/leetcode\.(com|cn).*\/discuss\/.*/i.test(url);
  718. const isProblem = (url = window.location.href) => /^https?:\/\/leetcode\.(com|cn)\/problems\/.*/i.test(url);
  719. const isContest = (url = window.location.href) => /^https?:\/\/leetcode\.(com|cn)\/contest\/.*\/problems\/.*/.test(url);
  720. const isBilibili = (url = window.location.href) => /.*bilibili.*/.test(url);
  721. const isZH = (url = window.location.href) => /^https?:\/\/leetcode\.cn/.test(url);
  722. const sleep = async (time = 500) => new Promise((resolove) => setTimeout(resolove, time));
  723. const EN_URL = "https://leetcode.com";
  724. const ZH_URL = "https://leetcode.cn";
  725. const LC_COPY_HTML_PLUGIN = "https://greasyfork.org/zh-CN/scripts/491969-lc-to-markdown-txt-html";
  726. const EN_SOLUTION_DEMO = "https://leetcode.com/discuss/interview-question/6032972/leetcode";
  727. const CUR_URL = isEnglishENV() ? EN_URL : ZH_URL;
  728. const isDev = () => JSON.parse("false");
  729. async function GetHubJSONInfo(url) {
  730. return fetch(url, {
  731. method: "get",
  732. mode: "cors"
  733. }).then((res) => res.json());
  734. }
  735. async function getProblemsJSON() {
  736. return GetHubJSONInfo("https://raw.githubusercontent.com/wuxin0011/tampermonkey-script/main/0x3f-leetcode/0x3f.json");
  737. }
  738. const LEETCODE_PROBLEM_API = `${CUR_URL}/graphql/`;
  739. async function PostLeetCodeApi(data) {
  740. return fetch(LEETCODE_PROBLEM_API, {
  741. method: "POST",
  742. credentials: "include",
  743. headers: {
  744. "Content-Type": "application/json"
  745. },
  746. body: JSON.stringify(data)
  747. }).then((res) => res.json());
  748. }
  749. async function getProblemAcInfo(titleSlug) {
  750. return PostLeetCodeApi(postData(titleSlug));
  751. }
  752. const _export_sfc = (sfc, props) => {
  753. const target = sfc.__vccOpts || sfc;
  754. for (const [key, val] of props) {
  755. target[key] = val;
  756. }
  757. return target;
  758. };
  759. const _sfc_main$1 = {};
  760. const _withScopeId = (n) => (vue.pushScopeId("data-v-d1230ce3"), n = n(), vue.popScopeId(), n);
  761. const _hoisted_1$1 = /* @__PURE__ */ vue.createStaticVNode('<h2 data-v-d1230ce3> 🎈必读内容 </h2><ul data-v-d1230ce3><li style="color:red !important;" data-v-d1230ce3> 同步功能使用前请确保为登录状态 </li></ul><h2 data-v-d1230ce3> ❓ 题单进度不一致 </h2><ul data-v-d1230ce3><li data-v-d1230ce3> 防止一次性访问题单太多,对服务器产生压力,所以采用单个题单访问然后保存状态 , 这样避免访问量问题 </li><li data-v-d1230ce3> 默认情况下会缓存访问的题单情况,对于没有访问的题单,可以手动在对应题单中同步 </li><li data-v-d1230ce3> 题目状态根据用户提交题目情况会实时更新,只会在提交访问一次 </li></ul><h2 data-v-d1230ce3> ❓ 如何使用随机题目? </h2><ul data-v-d1230ce3><li data-v-d1230ce3> 这个可以根据自己要求,配置好之后,可以使用 <em data-v-d1230ce3> ctrl + alt + j </em> 触发 </li><li data-v-d1230ce3> 如果这个快捷键影响,可以在命令设置中关闭 </li></ul><h2 data-v-d1230ce3> ❓ 如何使用美服 </h2>', 7);
  762. const _hoisted_8 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("h2", null, " 🔗 反馈更新 ", -1));
  763. function _sfc_render(_ctx, _cache) {
  764. const _component_el_link = vue.resolveComponent("el-link");
  765. return vue.openBlock(), vue.createElementBlock("div", null, [
  766. _hoisted_1$1,
  767. vue.createElementVNode("ul", null, [
  768. vue.createElementVNode("li", null, [
  769. vue.createTextVNode(" 处于网络安全策略,对于不同网站请求有 "),
  770. vue.createVNode(_component_el_link, {
  771. underline: false,
  772. href: "https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS",
  773. type: "primary",
  774. target: "_blank"
  775. }, {
  776. default: vue.withCtx(() => [
  777. vue.createTextVNode("跨域机制保护")
  778. ]),
  779. _: 1
  780. }),
  781. vue.createTextVNode(" 美服和国服是两个不同网站,因此无法实现不同网站题单同步 。 ")
  782. ]),
  783. vue.createElementVNode("li", null, [
  784. vue.createTextVNode(" 如果想使用美服,请复制一份题单到美服中 "),
  785. vue.createVNode(_component_el_link, {
  786. underline: false,
  787. href: "https://greasyfork.org/zh-CN/scripts/491969-lc-to-markdown-txt-html",
  788. type: "primary",
  789. target: "_blank"
  790. }, {
  791. default: vue.withCtx(() => [
  792. vue.createTextVNode("lc-to-markdown-txt-html")
  793. ]),
  794. _: 1
  795. }),
  796. vue.createTextVNode(" 这个插件来复制题单 ")
  797. ]),
  798. vue.createElementVNode("li", null, [
  799. vue.createVNode(_component_el_link, {
  800. underline: false,
  801. href: "https://leetcode.com/discuss/interview-question/6032972/leetcode",
  802. type: "primary",
  803. target: "_blank"
  804. }, {
  805. default: vue.withCtx(() => [
  806. vue.createTextVNode("美服题单演示")
  807. ]),
  808. _: 1
  809. })
  810. ])
  811. ]),
  812. _hoisted_8,
  813. vue.createElementVNode("ul", null, [
  814. vue.createElementVNode("li", null, [
  815. vue.createTextVNode(" 你可以在 "),
  816. vue.createVNode(_component_el_link, {
  817. underline: false,
  818. href: "https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback",
  819. type: "success",
  820. target: "_blank"
  821. }, {
  822. default: vue.withCtx(() => [
  823. vue.createTextVNode("油猴")
  824. ]),
  825. _: 1
  826. }),
  827. vue.createTextVNode("   "),
  828. vue.createVNode(_component_el_link, {
  829. underline: false,
  830. href: "https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback",
  831. type: "success",
  832. target: "_blank"
  833. }, {
  834. default: vue.withCtx(() => [
  835. vue.createTextVNode("脚本猫")
  836. ]),
  837. _: 1
  838. }),
  839. vue.createTextVNode(" 中更新或下载 ")
  840. ]),
  841. vue.createElementVNode("li", null, [
  842. vue.createVNode(_component_el_link, {
  843. underline: false,
  844. href: "https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback",
  845. type: "primary",
  846. target: "_blank"
  847. }, {
  848. default: vue.withCtx(() => [
  849. vue.createTextVNode("点击")
  850. ]),
  851. _: 1
  852. }),
  853. vue.createTextVNode("这里反馈 或者 "),
  854. vue.createVNode(_component_el_link, {
  855. target: "_blank",
  856. underline: false,
  857. href: "https://github.com/wuxin0011/tampermonkey-script/issues",
  858. type: "primary"
  859. }, {
  860. default: vue.withCtx(() => [
  861. vue.createTextVNode("issues")
  862. ]),
  863. _: 1
  864. })
  865. ])
  866. ])
  867. ]);
  868. }
  869. const Q1 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-d1230ce3"]]);
  870. function Message(title = "确认操作", callback = () => {
  871. }, canlcelCallback = () => {
  872. }) {
  873. ElementPlus.ElMessageBox.confirm(
  874. `${title} ?`,
  875. "警告",
  876. {
  877. confirmButtonText: "确认",
  878. cancelButtonText: "取消",
  879. type: "warning"
  880. }
  881. ).then(() => {
  882. callback();
  883. }).catch(() => {
  884. ElementPlus.ElMessage({
  885. type: "info",
  886. message: "已取消"
  887. });
  888. canlcelCallback();
  889. });
  890. }
  891. function tips_message() {
  892. if (isEnglish() && isZH() && Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"]) == "OK") {
  893. ElementPlus.ElMessageBox.alert(
  894. `<div>
  895. <p>检查到当前环境为国服,如果需要同步功能需要切换到美服,或者复制一份题单到美服自己使用 否则仅保留替换链接功能,没有同步功能 </p>
  896. <ul>
  897. <li>你可以使用<a style="color:blue;" target="_blank" href="${LC_COPY_HTML_PLUGIN}">lc-to-markdown-txt-html</a> 来复制题单 </li>
  898. <li><a style="color:red;" target="_blank" href="${EN_SOLUTION_DEMO}">查看美服题单示例</a> </li>
  899. <ul>
  900. <div>`,
  901. "提示",
  902. {
  903. dangerouslyUseHTMLString: true,
  904. showCancelButton: true,
  905. cancelButtonText: "下次再说",
  906. confirmButtonText: "不再提示"
  907. }
  908. ).then((e) => {
  909. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"], "NO");
  910. }).catch((e) => {
  911. if (e == "cancel") {
  912. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"]) == "OK_1";
  913. ElementPlus.ElMessage.warning({
  914. message: "下次切换到美服环境提示"
  915. });
  916. }
  917. });
  918. }
  919. }
  920. const _hoisted_1 = { class: "dialog-footer" };
  921. const _hoisted_2 = { class: "processs-flex" };
  922. const _hoisted_3 = { style: { "text-align": "center", "color": "#121212" } };
  923. const TARGET_URL = "https://leetcode.cn/u/endlesscheng/";
  924. const formLabelWidth = "44px";
  925. const _sfc_main = {
  926. __name: "App",
  927. setup(__props) {
  928. const fromData = vue.reactive(initObj());
  929. const tableButtonSize = vue.ref("default");
  930. let tableData = vue.reactive(initUrls());
  931. const keywords = vue.ref("");
  932. const dialogTableVisible = vue.ref(false);
  933. const showAddLocalButton = vue.computed(() => isLeetCodeCircleUrl());
  934. let urlsData = vue.computed(() => {
  935. let map = /* @__PURE__ */ new Map();
  936. let infos = tableData.filter((info2) => {
  937. if ((info2 == null ? void 0 : info2.title) && (info2 == null ? void 0 : info2.link) && !map.has(info2.link)) {
  938. map.set(info2.link, info2);
  939. return info2 && (info2.title && info2.title.indexOf(keywords.value) != -1 || info2.link && info2.link.indexOf(keywords.value) != -1);
  940. } else {
  941. return false;
  942. }
  943. });
  944. let tot = 0, ac = 0;
  945. for (let i = 0, c = info.length; i < infos.length; i++) {
  946. let info2 = infos[i];
  947. if (info2["ac"] && info2["tot"]) {
  948. tot += info2["tot"];
  949. ac += info2["ac"];
  950. }
  951. if (!info2["id"]) {
  952. info2["id"] = c + 1;
  953. c++;
  954. }
  955. }
  956. let type = isNaN(fromData.sortType) ? 0 : fromData.sortType;
  957. if (type == 0) {
  958. infos.sort((info1, info2) => info2.id - info1.id);
  959. } else if (type == 1) {
  960. infos.sort((info1, info2) => info2.tot - info1.tot);
  961. } else if (type == 2) {
  962. infos.sort((info1, info2) => info2.ac - info1.ac);
  963. } else if (type == 3) {
  964. infos.sort((info1, info2) => computeProcess(info2.ac, info2.tot) - computeProcess(info1.ac, info1.tot));
  965. }
  966. infos.unshift({ "title": "灵茶题单完成情况", "link": TARGET_URL, "tot": tot, "ac": ac, "id": 67108863 });
  967. return infos;
  968. });
  969. const rowIsDisabled = vue.computed(() => (info2) => asyncButtonLoad.value || info2 && info2.link == TARGET_URL);
  970. const isDisabbled = vue.computed(() => !!tableData.find((v) => (v == null ? void 0 : v.link) && (v == null ? void 0 : v.link.indexOf(window.location.href)) != -1));
  971. const dialogFormVisible = vue.ref(false);
  972. const computeProcess = (ac = 0, tot = 0) => {
  973. if (isNaN(ac) || isNaN(tot) || tot === 0) return 0;
  974. let p = 0;
  975. if (tot == ac) {
  976. return 100;
  977. }
  978. const s = String(ac / tot);
  979. try {
  980. let x1 = s.split(".")[1] || "";
  981. x1 = x1.padEnd(3, "0").substring(0, 3);
  982. p = Math.min(100, Number(x1) / 10);
  983. } catch (e) {
  984. console.log("calc error", e.message, s == void 0, ac, tot);
  985. p = (ac / tot).toFixed(3) * 100;
  986. }
  987. return isNaN(p) ? 0 : p;
  988. };
  989. const processColors = [
  990. { color: "#f56c6c", percentage: 20 },
  991. { color: "#1989fa", percentage: 40 },
  992. { color: "#e6a23c", percentage: 60 },
  993. { color: "#6f7ad3", percentage: 80 },
  994. { color: "#67c23a", percentage: 100 }
  995. ];
  996. vue.watch(fromData, () => {
  997. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  998. });
  999. const info = vue.reactive({
  1000. title: "",
  1001. link: "",
  1002. status: "add"
  1003. });
  1004. const addlocal = async () => {
  1005. if (!isDisabbled) {
  1006. return;
  1007. }
  1008. let [cur, tot] = await getProcess();
  1009. tableData.unshift({ title: document.title, link: window.location.href, "ac": cur, "tot": tot, "id": tableData.length + 10 });
  1010. };
  1011. const updateIndex = vue.ref(-1);
  1012. const handlerProblems = (status, updateInfo = { title: "", link: "", id: 0 }, index = -1) => {
  1013. dialogFormVisible.value = true;
  1014. info.status = status;
  1015. updateIndex.value = updateInfo.id;
  1016. Object.assign(info, updateInfo);
  1017. };
  1018. const handlerMessage = (u, title, link) => {
  1019. const a = u ? "添加" : "修改";
  1020. const error = !(!!title && isHttp(link));
  1021. if (error) {
  1022. ElementPlus.ElMessage.error(`${a} 失败 请保证标题或者链接有效 `);
  1023. } else {
  1024. ElementPlus.ElMessage.success(`${a} 成功 `);
  1025. }
  1026. return !error;
  1027. };
  1028. const addOrUpdate = () => {
  1029. if (!handlerMessage(info.status == "add", info.title, info.link)) {
  1030. return;
  1031. }
  1032. if (info.status == "add") {
  1033. tableData.unshift({ title: info.title, link: info.link, "ac": 0, "tot": 0, "id": tableData.length + 10 });
  1034. } else {
  1035. let id = updateIndex.value;
  1036. for (let i = 0; i < tableData.length; i++) {
  1037. if (tableData[i] && tableData[i].id && tableData[i]["id"] == id) {
  1038. tableData[i]["title"] = info.title;
  1039. tableData[i]["link"] = info.link;
  1040. break;
  1041. }
  1042. }
  1043. }
  1044. dialogFormVisible.value = false;
  1045. };
  1046. const deleteProblems = (id) => {
  1047. for (let i = 0; i < tableData.length; i++) {
  1048. if (tableData[i] && tableData[i].id && tableData[i]["id"] == id) {
  1049. delete tableData[i];
  1050. break;
  1051. }
  1052. }
  1053. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  1054. };
  1055. const handlerDefault = () => {
  1056. Message("确认使用默认题单,将会重置题单", () => {
  1057. for (let i = 0; i < tableData.length; i++) {
  1058. delete tableData[i];
  1059. }
  1060. let infos = computeAcInfo(defaultUrls);
  1061. for (let item of infos) {
  1062. tableData.unshift(item);
  1063. }
  1064. ElementPlus.ElMessage({
  1065. type: "success",
  1066. message: "重置成功"
  1067. });
  1068. });
  1069. };
  1070. window.addEventListener("beforeunload", () => {
  1071. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], vue.toRaw(tableData).filter((u) => u != null && u != void 0));
  1072. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_update__"], true);
  1073. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_add_cur__"], false);
  1074. });
  1075. vue.onMounted(async () => {
  1076. if (support_plugins()) {
  1077. let times = 30;
  1078. let loadTimeId = setInterval(() => {
  1079. let a = queryProblem();
  1080. times--;
  1081. if (Array.isArray(a) && a.length > 0) {
  1082. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  1083. addProcess();
  1084. window.clearInterval(loadTimeId);
  1085. }
  1086. if (times == 0) {
  1087. window.clearInterval(loadTimeId);
  1088. }
  1089. }, 200);
  1090. }
  1091. window.addEventListener("storage", (e) => {
  1092. watchLinkStatusUpdate(e);
  1093. });
  1094. });
  1095. _GM_registerMenuCommand(`题单配置信息🛠`, () => {
  1096. dialogTableVisible.value = !dialogTableVisible.value;
  1097. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  1098. const selectHandlerChange = (row) => {
  1099. let infos = [];
  1100. for (let i = 0; i < urlsData.value.length; i++) {
  1101. if (urlsData.value[i]["link"] == TARGET_URL) continue;
  1102. infos.push(vue.toRaw(Object.assign({}, urlsData.value[i])));
  1103. }
  1104. for (let i = 0; i < tableData.length; i++) {
  1105. if (row.id == tableData[i].id) {
  1106. tableData[i].select = row.select;
  1107. break;
  1108. }
  1109. }
  1110. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], infos);
  1111. };
  1112. const asyncButtonLoad = vue.ref(false);
  1113. const asyncButtonLoadBreak = vue.ref(false);
  1114. const showProcess = vue.ref(false);
  1115. const allProblemNum = vue.ref(0);
  1116. const asyncProblemNum = vue.ref(0);
  1117. const asyncVisableDialog = vue.ref(false);
  1118. const showProblemsProcessInfo = vue.reactive({
  1119. title: "",
  1120. link: "",
  1121. cnt: "",
  1122. ac: "",
  1123. id: "",
  1124. select: true
  1125. });
  1126. const showProblemsInfo = (info2 = {}) => {
  1127. asyncVisableDialog.value = !asyncVisableDialog.value;
  1128. Object.assign(showProblemsProcessInfo, info2);
  1129. };
  1130. const loadProcess = vue.computed(() => computeProcess(asyncProblemNum.value, allProblemNum.value));
  1131. const asyncProblemStatus = async (row = {}) => {
  1132. if (!(row == null ? void 0 : row.link)) return;
  1133. let callback = async () => {
  1134. var _a, _b, _c, _d, _e;
  1135. let rowData = void 0;
  1136. let asyncAll = (row == null ? void 0 : row.link) == TARGET_URL;
  1137. let cache = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name);
  1138. if (isDev()) {
  1139. console.log("async ac cache:", cache);
  1140. }
  1141. let map = /* @__PURE__ */ new Map();
  1142. try {
  1143. for (let info2 of tableData) {
  1144. if ((info2 == null ? void 0 : info2.link) && (info2 == null ? void 0 : info2.title) && (info2 == null ? void 0 : info2.id)) {
  1145. if (rowData == void 0 && (info2 == null ? void 0 : info2.id) == row.id) {
  1146. rowData = info2;
  1147. }
  1148. if (!map.has(info2.link)) {
  1149. map.set(info2.link, info2);
  1150. }
  1151. }
  1152. }
  1153. if (rowData) {
  1154. rowData.loading = true;
  1155. }
  1156. asyncButtonLoad.value = true;
  1157. asyncButtonLoadBreak.value = false;
  1158. allProblemNum.value = 0;
  1159. asyncProblemNum.value = 0;
  1160. showProcess.value = true;
  1161. await sleep(500);
  1162. let githubInfo = await githubProblem(fromData.visiableMember);
  1163. let jsonInfo = githubInfo[2];
  1164. let datas = [];
  1165. for (let i = 0; Array.isArray(jsonInfo) && i < jsonInfo.length; i++) {
  1166. let key = `${(_a = jsonInfo[i]) == null ? void 0 : _a.problemUrl}`;
  1167. let origin = map.get(key);
  1168. if (!origin) {
  1169. continue;
  1170. }
  1171. if (asyncAll) {
  1172. for (let p of jsonInfo[i].problems) {
  1173. datas.push(Object.assign({ "origin": jsonInfo[i].problemUrl }, p));
  1174. }
  1175. origin.tot = Math.max(jsonInfo[i].problems.length, 0);
  1176. origin.ac = 0;
  1177. } else if (jsonInfo[i].problemUrl == row.link) {
  1178. for (let p of jsonInfo[i].problems) {
  1179. datas.push(Object.assign({ "origin": jsonInfo[i].problemUrl }, p));
  1180. }
  1181. origin.tot = Math.max(jsonInfo[i].problems.length, 0);
  1182. origin.ac = 0;
  1183. break;
  1184. }
  1185. }
  1186. if (Array.isArray(datas) && datas.length > 0) {
  1187. allProblemNum.value = datas.length;
  1188. asyncProblemNum.value = 0;
  1189. let pre = 0;
  1190. for (let i = 0; i < datas.length; i++) {
  1191. let info2 = datas[i];
  1192. try {
  1193. if (asyncButtonLoadBreak.value) {
  1194. break;
  1195. }
  1196. await sleep(80);
  1197. let ID2 = info2.titleSlug;
  1198. let key = `${info2.origin}`;
  1199. let origin = map.get(key);
  1200. if (cache[ID2] != "ac") {
  1201. let response = await getProblemAcInfo(ID2);
  1202. const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status;
  1203. cache[ID2] = status == null ? "null" : status;
  1204. }
  1205. if (origin) {
  1206. if (cache[ID2] == "ac") {
  1207. origin.ac = origin.ac + 1;
  1208. }
  1209. }
  1210. asyncProblemNum.value += 1;
  1211. if (loadProcess.value < pre && isDev()) {
  1212. console.warn("calc result is error");
  1213. }
  1214. pre = loadProcess.value;
  1215. } catch (e) {
  1216. if (isDev()) {
  1217. console.log("process error", e.message, "asyncProblemNum.value", asyncProblemNum.value, "all", allProblemNum.value);
  1218. }
  1219. }
  1220. if (i % 100 == 0) {
  1221. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], Object.assign({}, cache));
  1222. }
  1223. }
  1224. }
  1225. } catch (e) {
  1226. console.log("error", e);
  1227. } finally {
  1228. if (rowData) {
  1229. rowData.loading = false;
  1230. }
  1231. asyncButtonLoad.value = false;
  1232. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  1233. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], Object.assign({}, cache));
  1234. if (isDev()) {
  1235. console.log("同步完成🥰", asyncProblemNum.value, allProblemNum.value, loadProcess.value);
  1236. }
  1237. await sleep(500);
  1238. ElementPlus.ElMessage({
  1239. type: allProblemNum.value == asyncProblemNum.value ? "success" : asyncButtonLoadBreak.value ? "error" : "warning",
  1240. message: allProblemNum.value == asyncProblemNum.value ? `同步完成🥰` : asyncButtonLoadBreak.value ? `同步中断 ${loadProcess.value}% ` : `同步率 ${loadProcess.value}% `,
  1241. duration: 3e3
  1242. });
  1243. await sleep(6e3);
  1244. allProblemNum.value = 0;
  1245. asyncProblemNum.value = 0;
  1246. showProcess.value = false;
  1247. asyncButtonLoadBreak.value = false;
  1248. for (let i = 0; i < tableData.length; i++) {
  1249. if (getAcCountKey((_d = tableData[i]) == null ? void 0 : _d.link)) {
  1250. Cache$2.set(getAcCountKey(tableData[i].link), { "tot": tableData[i].tot, "ac": tableData[i].ac });
  1251. }
  1252. if ((_e = tableData[i]) == null ? void 0 : _e.loading) {
  1253. tableData[i].loading = false;
  1254. }
  1255. }
  1256. }
  1257. };
  1258. if (row.link == TARGET_URL) {
  1259. Message("该操作将同步所有题单,耗时可能较长 确认操作?", callback);
  1260. } else {
  1261. callback();
  1262. }
  1263. };
  1264. const q1 = vue.ref(false);
  1265. vue.ref(false);
  1266. return (_ctx, _cache) => {
  1267. const _component_el_dialog = vue.resolveComponent("el-dialog");
  1268. const _component_el_input = vue.resolveComponent("el-input");
  1269. const _component_el_form_item = vue.resolveComponent("el-form-item");
  1270. const _component_el_form = vue.resolveComponent("el-form");
  1271. const _component_el_button = vue.resolveComponent("el-button");
  1272. const _component_el_progress = vue.resolveComponent("el-progress");
  1273. const _component_el_col = vue.resolveComponent("el-col");
  1274. const _component_el_option = vue.resolveComponent("el-option");
  1275. const _component_el_select = vue.resolveComponent("el-select");
  1276. const _component_el_tooltip = vue.resolveComponent("el-tooltip");
  1277. const _component_el_row = vue.resolveComponent("el-row");
  1278. const _component_el_table_column = vue.resolveComponent("el-table-column");
  1279. const _component_el_link = vue.resolveComponent("el-link");
  1280. const _component_el_switch = vue.resolveComponent("el-switch");
  1281. const _component_el_table = vue.resolveComponent("el-table");
  1282. return vue.openBlock(), vue.createElementBlock("div", null, [
  1283. vue.createVNode(_component_el_dialog, {
  1284. modelValue: q1.value,
  1285. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => q1.value = $event)
  1286. }, {
  1287. default: vue.withCtx(() => [
  1288. vue.createVNode(Q1)
  1289. ]),
  1290. _: 1
  1291. }, 8, ["modelValue"]),
  1292. vue.createVNode(_component_el_dialog, {
  1293. modelValue: dialogFormVisible.value,
  1294. "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => dialogFormVisible.value = $event),
  1295. title: `${info.status == "add" ? "添加" : "编辑"}`,
  1296. width: "400"
  1297. }, {
  1298. footer: vue.withCtx(() => [
  1299. vue.createElementVNode("div", _hoisted_1, [
  1300. vue.createVNode(_component_el_button, {
  1301. onClick: _cache[3] || (_cache[3] = ($event) => dialogFormVisible.value = false)
  1302. }, {
  1303. default: vue.withCtx(() => [
  1304. vue.createTextVNode("取消")
  1305. ]),
  1306. _: 1
  1307. }),
  1308. vue.createVNode(_component_el_button, { onClick: addOrUpdate }, {
  1309. default: vue.withCtx(() => [
  1310. vue.createTextVNode(" 确认 ")
  1311. ]),
  1312. _: 1
  1313. })
  1314. ])
  1315. ]),
  1316. default: vue.withCtx(() => [
  1317. vue.createVNode(_component_el_form, null, {
  1318. default: vue.withCtx(() => [
  1319. vue.createVNode(_component_el_form_item, {
  1320. label: "标题",
  1321. "label-width": formLabelWidth
  1322. }, {
  1323. default: vue.withCtx(() => [
  1324. vue.createVNode(_component_el_input, {
  1325. modelValue: info.title,
  1326. "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => info.title = $event),
  1327. autocomplete: "off"
  1328. }, null, 8, ["modelValue"])
  1329. ]),
  1330. _: 1
  1331. }),
  1332. vue.createVNode(_component_el_form_item, {
  1333. label: "链接",
  1334. "label-width": formLabelWidth
  1335. }, {
  1336. default: vue.withCtx(() => [
  1337. vue.createVNode(_component_el_input, {
  1338. modelValue: info.link,
  1339. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => info.link = $event),
  1340. autocomplete: "off"
  1341. }, null, 8, ["modelValue"])
  1342. ]),
  1343. _: 1
  1344. })
  1345. ]),
  1346. _: 1
  1347. })
  1348. ]),
  1349. _: 1
  1350. }, 8, ["modelValue", "title"]),
  1351. vue.createVNode(_component_el_dialog, {
  1352. modelValue: dialogTableVisible.value,
  1353. "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => dialogTableVisible.value = $event),
  1354. title: asyncButtonLoadBreak.value ? `同步已中断 ${asyncProblemNum.value}/${allProblemNum.value}` : showProcess.value ? loadProcess.value < 100 ? `同步中...${asyncProblemNum.value}/${allProblemNum.value}` : "统计完成" : "题单信息",
  1355. width: "60%"
  1356. }, {
  1357. default: vue.withCtx(() => [
  1358. showProcess.value ? (vue.openBlock(), vue.createBlock(_component_el_progress, {
  1359. key: 0,
  1360. color: processColors,
  1361. percentage: loadProcess.value,
  1362. "stroke-width": 15,
  1363. striped: "",
  1364. "striped-flow": "",
  1365. style: { "margin-bottom": "20px" },
  1366. status: `${loadProcess.value == 100 ? "success" : ""}`
  1367. }, null, 8, ["percentage", "status"])) : vue.createCommentVNode("", true),
  1368. vue.createVNode(_component_el_row, { gutter: 10 }, {
  1369. default: vue.withCtx(() => [
  1370. vue.createVNode(_component_el_col, { span: 4 }, {
  1371. default: vue.withCtx(() => [
  1372. vue.createVNode(_component_el_input, {
  1373. modelValue: keywords.value,
  1374. "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => keywords.value = $event),
  1375. placeholder: "请输入关键词过滤",
  1376. clearable: ""
  1377. }, null, 8, ["modelValue"])
  1378. ]),
  1379. _: 1
  1380. }),
  1381. vue.createVNode(_component_el_col, { span: 20 }, {
  1382. default: vue.withCtx(() => [
  1383. showAddLocalButton.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1384. key: 0,
  1385. plain: "",
  1386. onClick: addlocal,
  1387. disabled: isDisabbled.value,
  1388. size: tableButtonSize.value
  1389. }, {
  1390. default: vue.withCtx(() => [
  1391. vue.createTextVNode(" 添加本页 ")
  1392. ]),
  1393. _: 1
  1394. }, 8, ["disabled", "size"])) : vue.createCommentVNode("", true),
  1395. showAddLocalButton.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1396. key: 1,
  1397. plain: "",
  1398. onClick: _cache[6] || (_cache[6] = ($event) => handlerProblems("add")),
  1399. size: tableButtonSize.value
  1400. }, {
  1401. default: vue.withCtx(() => [
  1402. vue.createTextVNode(" 自定义 ")
  1403. ]),
  1404. _: 1
  1405. }, 8, ["size"])) : vue.createCommentVNode("", true),
  1406. vue.createVNode(_component_el_select, {
  1407. modelValue: fromData.sortType,
  1408. "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => fromData.sortType = $event),
  1409. style: { "margin": "0 5px", "width": "100px" },
  1410. disabled: asyncButtonLoad.value
  1411. }, {
  1412. default: vue.withCtx(() => [
  1413. vue.createVNode(_component_el_option, {
  1414. label: "默认排序",
  1415. value: 0
  1416. }, {
  1417. default: vue.withCtx(() => [
  1418. vue.createTextVNode("默认排序")
  1419. ]),
  1420. _: 1
  1421. }),
  1422. vue.createVNode(_component_el_option, {
  1423. label: "题目数量",
  1424. value: 1
  1425. }, {
  1426. default: vue.withCtx(() => [
  1427. vue.createTextVNode("题目数量")
  1428. ]),
  1429. _: 1
  1430. }),
  1431. vue.createVNode(_component_el_option, {
  1432. label: "AC数量",
  1433. value: 2
  1434. }, {
  1435. default: vue.withCtx(() => [
  1436. vue.createTextVNode("AC数量")
  1437. ]),
  1438. _: 1
  1439. }),
  1440. vue.createVNode(_component_el_option, {
  1441. label: "完成度",
  1442. value: 3
  1443. }, {
  1444. default: vue.withCtx(() => [
  1445. vue.createTextVNode("完成度")
  1446. ]),
  1447. _: 1
  1448. })
  1449. ]),
  1450. _: 1
  1451. }, 8, ["modelValue", "disabled"]),
  1452. vue.createVNode(_component_el_tooltip, { content: "同步所有题单" }, {
  1453. default: vue.withCtx(() => [
  1454. vue.createVNode(_component_el_button, {
  1455. type: asyncButtonLoad.value ? "success" : "danger",
  1456. onClick: _cache[8] || (_cache[8] = ($event) => asyncProblemStatus({ "link": "https://leetcode.cn/u/endlesscheng/" })),
  1457. size: tableButtonSize.value,
  1458. loading: asyncButtonLoad.value
  1459. }, {
  1460. default: vue.withCtx(() => [
  1461. vue.createTextVNode(vue.toDisplayString(asyncButtonLoad.value ? "同步中" : "同步题单"), 1)
  1462. ]),
  1463. _: 1
  1464. }, 8, ["type", "size", "loading"])
  1465. ]),
  1466. _: 1
  1467. }),
  1468. asyncButtonLoad.value ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
  1469. key: 2,
  1470. content: "点击中断同步"
  1471. }, {
  1472. default: vue.withCtx(() => [
  1473. asyncButtonLoad.value ? (vue.openBlock(), vue.createBlock(_component_el_button, {
  1474. key: 0,
  1475. type: "warning",
  1476. text: "",
  1477. onClick: _cache[9] || (_cache[9] = ($event) => asyncButtonLoadBreak.value = !asyncButtonLoadBreak.value),
  1478. size: tableButtonSize.value
  1479. }, {
  1480. default: vue.withCtx(() => [
  1481. vue.createTextVNode(" 中断同步 ")
  1482. ]),
  1483. _: 1
  1484. }, 8, ["size"])) : vue.createCommentVNode("", true)
  1485. ]),
  1486. _: 1
  1487. })) : vue.createCommentVNode("", true),
  1488. vue.createVNode(_component_el_tooltip, { content: "随机一道灵茶题单中题目,快捷键 Ctrl + Alt + J 可以触发" }, {
  1489. default: vue.withCtx(() => [
  1490. vue.createVNode(_component_el_button, {
  1491. type: "primary",
  1492. text: "",
  1493. onClick: vue.unref(randomProblem),
  1494. size: tableButtonSize.value
  1495. }, {
  1496. default: vue.withCtx(() => [
  1497. vue.createTextVNode(" 随机题目 ")
  1498. ]),
  1499. _: 1
  1500. }, 8, ["onClick", "size"])
  1501. ]),
  1502. _: 1
  1503. })
  1504. ]),
  1505. _: 1
  1506. })
  1507. ]),
  1508. _: 1
  1509. }),
  1510. vue.createVNode(_component_el_table, {
  1511. data: vue.unref(urlsData),
  1512. height: "300",
  1513. style: { "width": "100%", "margin-top": "10px" }
  1514. }, {
  1515. default: vue.withCtx(() => [
  1516. vue.createVNode(_component_el_table_column, { type: "index" }),
  1517. vue.createVNode(_component_el_table_column, {
  1518. label: "标题",
  1519. width: "auto",
  1520. align: "center"
  1521. }, {
  1522. default: vue.withCtx((scope) => [
  1523. vue.createVNode(_component_el_link, {
  1524. href: scope.row.link,
  1525. target: "_blank",
  1526. type: "default"
  1527. }, {
  1528. default: vue.withCtx(() => [
  1529. vue.createTextVNode(vue.toDisplayString(scope.row.title), 1)
  1530. ]),
  1531. _: 2
  1532. }, 1032, ["href"])
  1533. ]),
  1534. _: 1
  1535. }),
  1536. vue.createVNode(_component_el_table_column, {
  1537. label: "随机",
  1538. width: "70",
  1539. align: "center"
  1540. }, {
  1541. default: vue.withCtx((scope) => [
  1542. vue.createVNode(_component_el_switch, {
  1543. modelValue: scope.row.select,
  1544. "onUpdate:modelValue": ($event) => scope.row.select = $event,
  1545. onChange: ($event) => selectHandlerChange(scope.row),
  1546. disabled: rowIsDisabled.value(scope.row),
  1547. size: "small"
  1548. }, null, 8, ["modelValue", "onUpdate:modelValue", "onChange", "disabled"])
  1549. ]),
  1550. _: 1
  1551. }),
  1552. vue.createVNode(_component_el_table_column, {
  1553. label: "AC",
  1554. width: "70",
  1555. align: "center"
  1556. }, {
  1557. default: vue.withCtx((scope) => [
  1558. vue.createVNode(_component_el_link, {
  1559. type: "success",
  1560. underline: false,
  1561. onClick: ($event) => showProblemsInfo(scope.row)
  1562. }, {
  1563. default: vue.withCtx(() => [
  1564. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.ac) ? 0 : scope.row.ac), 1)
  1565. ]),
  1566. _: 2
  1567. }, 1032, ["onClick"])
  1568. ]),
  1569. _: 1
  1570. }),
  1571. vue.createVNode(_component_el_table_column, {
  1572. label: "Total",
  1573. width: "70",
  1574. align: "center"
  1575. }, {
  1576. default: vue.withCtx((scope) => [
  1577. vue.createVNode(_component_el_link, {
  1578. type: "primary",
  1579. underline: false,
  1580. onClick: ($event) => showProblemsInfo(scope.row)
  1581. }, {
  1582. default: vue.withCtx(() => [
  1583. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.tot) ? 0 : scope.row.tot), 1)
  1584. ]),
  1585. _: 2
  1586. }, 1032, ["onClick"])
  1587. ]),
  1588. _: 1
  1589. }),
  1590. vue.createVNode(_component_el_table_column, {
  1591. label: "进度",
  1592. width: "70",
  1593. align: "center"
  1594. }, {
  1595. default: vue.withCtx((scope) => [
  1596. vue.createVNode(_component_el_link, {
  1597. onClick: ($event) => showProblemsInfo(scope.row),
  1598. type: "warning",
  1599. underline: false
  1600. }, {
  1601. default: vue.withCtx(() => {
  1602. var _a, _b, _c;
  1603. return [
  1604. 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)
  1605. ];
  1606. }),
  1607. _: 2
  1608. }, 1032, ["onClick"])
  1609. ]),
  1610. _: 1
  1611. }),
  1612. vue.createVNode(_component_el_table_column, {
  1613. label: "操作",
  1614. width: "200px",
  1615. align: "center"
  1616. }, {
  1617. default: vue.withCtx((scope) => [
  1618. vue.createVNode(_component_el_button, {
  1619. loading: scope.row.loading,
  1620. onClick: ($event) => asyncProblemStatus(scope.row),
  1621. size: "small",
  1622. type: "success",
  1623. disabled: rowIsDisabled.value(scope.row),
  1624. link: ""
  1625. }, {
  1626. default: vue.withCtx(() => [
  1627. vue.createTextVNode(vue.toDisplayString(scope.row.loading ? "" : "同步"), 1)
  1628. ]),
  1629. _: 2
  1630. }, 1032, ["loading", "onClick", "disabled"]),
  1631. vue.createVNode(_component_el_button, {
  1632. onClick: ($event) => handlerProblems("update", scope.row, scope.$index),
  1633. size: "small",
  1634. type: "primary",
  1635. disabled: rowIsDisabled.value(scope.row),
  1636. link: ""
  1637. }, {
  1638. default: vue.withCtx(() => [
  1639. vue.createTextVNode("编辑")
  1640. ]),
  1641. _: 2
  1642. }, 1032, ["onClick", "disabled"]),
  1643. vue.createVNode(_component_el_button, {
  1644. onClick: ($event) => deleteProblems(scope.row.id),
  1645. size: "small",
  1646. type: "danger",
  1647. link: "",
  1648. disabled: rowIsDisabled.value(scope.row)
  1649. }, {
  1650. default: vue.withCtx(() => [
  1651. vue.createTextVNode("删除")
  1652. ]),
  1653. _: 2
  1654. }, 1032, ["onClick", "disabled"])
  1655. ]),
  1656. _: 1
  1657. })
  1658. ]),
  1659. _: 1
  1660. }, 8, ["data"]),
  1661. vue.createVNode(_component_el_row, {
  1662. gutter: 10,
  1663. style: { "margin": "10px 0" }
  1664. }, {
  1665. default: vue.withCtx(() => [
  1666. vue.createVNode(_component_el_col, { span: 10 }, {
  1667. default: vue.withCtx(() => [
  1668. vue.createTextVNode(" 会员  "),
  1669. vue.createVNode(_component_el_tooltip, { content: "过滤会员题目,会员题不会出现在随机题目中和讨论区显示。另外会员题目将不参与进度统计,默认显示" }, {
  1670. default: vue.withCtx(() => [
  1671. vue.createVNode(_component_el_switch, {
  1672. modelValue: fromData.visiableMember,
  1673. "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => fromData.visiableMember = $event)
  1674. }, null, 8, ["modelValue"])
  1675. ]),
  1676. _: 1
  1677. }),
  1678. showAddLocalButton.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
  1679. vue.createTextVNode(" 隐藏AC  "),
  1680. vue.createVNode(_component_el_tooltip, { content: "是否在讨论区显示AC题目,默认显示 " }, {
  1681. default: vue.withCtx(() => [
  1682. vue.createVNode(_component_el_switch, {
  1683. modelValue: fromData.hiddenAc,
  1684. "onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => fromData.hiddenAc = $event)
  1685. }, null, 8, ["modelValue"])
  1686. ]),
  1687. _: 1
  1688. })
  1689. ], 64)) : vue.createCommentVNode("", true),
  1690. vue.createTextVNode(" 随机ac  "),
  1691. vue.createVNode(_component_el_tooltip, { content: "随机题目配置: 过滤AC的题目,AC题目出现在随机题目中,默认不过滤" }, {
  1692. default: vue.withCtx(() => [
  1693. vue.createVNode(_component_el_switch, {
  1694. modelValue: fromData.showAcConfig,
  1695. "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => fromData.showAcConfig = $event)
  1696. }, null, 8, ["modelValue"])
  1697. ]),
  1698. _: 1
  1699. })
  1700. ]),
  1701. _: 1
  1702. }),
  1703. vue.createVNode(_component_el_col, { span: 8 }, {
  1704. default: vue.withCtx(() => [
  1705. vue.createTextVNode("   "),
  1706. vue.createVNode(_component_el_tooltip, { content: "随机题目和讨论区题目将会在这个区间(没有分数题目无法操作)" }, {
  1707. default: vue.withCtx(() => [
  1708. vue.createVNode(_component_el_link, {
  1709. underline: false,
  1710. type: "primary"
  1711. }, {
  1712. default: vue.withCtx(() => [
  1713. vue.createTextVNode("分数区间")
  1714. ]),
  1715. _: 1
  1716. })
  1717. ]),
  1718. _: 1
  1719. }),
  1720. vue.createTextVNode("   "),
  1721. vue.createVNode(_component_el_input, {
  1722. modelValue: fromData.min,
  1723. "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => fromData.min = $event),
  1724. "aria-placeholder": "",
  1725. placeholder: " min ",
  1726. style: { "width": "60px" }
  1727. }, null, 8, ["modelValue"]),
  1728. vue.createTextVNode("- "),
  1729. vue.createVNode(_component_el_input, {
  1730. modelValue: fromData.max,
  1731. "onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => fromData.max = $event),
  1732. "aria-placeholder": "",
  1733. placeholder: " max",
  1734. style: { "width": "60px" }
  1735. }, null, 8, ["modelValue"])
  1736. ]),
  1737. _: 1
  1738. }),
  1739. vue.createVNode(_component_el_col, { span: 6 }, {
  1740. default: vue.withCtx(() => [
  1741. vue.createVNode(_component_el_tooltip, { content: "重置题单" }, {
  1742. default: vue.withCtx(() => [
  1743. vue.createVNode(_component_el_button, {
  1744. plain: "",
  1745. onClick: handlerDefault,
  1746. size: tableButtonSize.value,
  1747. disabled: showProcess.value
  1748. }, {
  1749. default: vue.withCtx(() => [
  1750. vue.createTextVNode(" 默认 ")
  1751. ]),
  1752. _: 1
  1753. }, 8, ["size", "disabled"])
  1754. ]),
  1755. _: 1
  1756. }),
  1757. vue.createVNode(_component_el_button, {
  1758. plain: "",
  1759. onClick: _cache[15] || (_cache[15] = ($event) => q1.value = !q1.value),
  1760. size: tableButtonSize.value
  1761. }, {
  1762. default: vue.withCtx(() => [
  1763. vue.createTextVNode(" 使用说明 ")
  1764. ]),
  1765. _: 1
  1766. }, 8, ["size"])
  1767. ]),
  1768. _: 1
  1769. })
  1770. ]),
  1771. _: 1
  1772. })
  1773. ]),
  1774. _: 1
  1775. }, 8, ["modelValue", "title"]),
  1776. vue.createVNode(_component_el_dialog, {
  1777. modelValue: asyncVisableDialog.value,
  1778. "onUpdate:modelValue": _cache[17] || (_cache[17] = ($event) => asyncVisableDialog.value = $event),
  1779. width: "35%"
  1780. }, {
  1781. default: vue.withCtx(() => [
  1782. vue.createElementVNode("p", null, [
  1783. vue.createVNode(_component_el_link, {
  1784. href: showProblemsProcessInfo.link,
  1785. type: "info",
  1786. underline: false
  1787. }, {
  1788. default: vue.withCtx(() => [
  1789. vue.createTextVNode(vue.toDisplayString(showProblemsProcessInfo.title), 1)
  1790. ]),
  1791. _: 1
  1792. }, 8, ["href"])
  1793. ]),
  1794. vue.createElementVNode("div", _hoisted_2, [
  1795. vue.createVNode(_component_el_progress, {
  1796. type: "circle",
  1797. percentage: computeProcess(showProblemsProcessInfo.ac, showProblemsProcessInfo.tot),
  1798. color: processColors
  1799. }, {
  1800. default: vue.withCtx(({ percentage }) => [
  1801. vue.createElementVNode("p", null, vue.toDisplayString(percentage) + "%", 1)
  1802. ]),
  1803. _: 1
  1804. }, 8, ["percentage"])
  1805. ]),
  1806. vue.createElementVNode("p", _hoisted_3, vue.toDisplayString(showProblemsProcessInfo.ac) + " / " + vue.toDisplayString(showProblemsProcessInfo.tot), 1)
  1807. ]),
  1808. _: 1
  1809. }, 8, ["modelValue"])
  1810. ]);
  1811. };
  1812. }
  1813. };
  1814. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-76dd1ba0"]]);
  1815. const cssLoader = (e) => {
  1816. const t = GM_getResourceText(e);
  1817. return GM_addStyle(t), t;
  1818. };
  1819. cssLoader("elementPlusCss");
  1820. const stopRankingKey = "__is_stop_rating_ranking__";
  1821. let conetstTimeId = null;
  1822. function run$1() {
  1823. const container = document.querySelector(".contest-question-info .list-group");
  1824. if (!container) return;
  1825. const ls = Array.from(container.querySelectorAll(".list-group-item .pull-right"));
  1826. for (let i = 0; i < 4; i++) {
  1827. if (i >= ls.length) {
  1828. break;
  1829. }
  1830. if (ls[i] instanceof HTMLElement) {
  1831. ls[i].textContent = "0";
  1832. }
  1833. }
  1834. window.clearInterval(conetstTimeId);
  1835. }
  1836. function startStopRanking() {
  1837. if (!isContest(window.location.href)) {
  1838. return;
  1839. }
  1840. const isNext = !!document.querySelector("#__next");
  1841. if (isNext) {
  1842. return;
  1843. }
  1844. const use = Cache$2.get(stopRankingKey);
  1845. if (use) {
  1846. conetstTimeId = setInterval(() => {
  1847. run$1();
  1848. }, 10);
  1849. }
  1850. _GM_registerMenuCommand(`${use ? "使用" : "关闭"} 排行榜`, () => {
  1851. Cache$2.set(stopRankingKey, !use);
  1852. window.location.reload();
  1853. }, { title: "对于不想看到排行榜的可以使用此功能 默认开启" });
  1854. }
  1855. const local_url$1 = window.location.href;
  1856. let loadID$1 = 0;
  1857. let submitCnt = 0;
  1858. let submitbutton = null;
  1859. function watchDom(dom) {
  1860. if (!(dom instanceof HTMLElement)) {
  1861. return;
  1862. }
  1863. let m = new MutationObserver(() => {
  1864. if (submitCnt % 2 == 1) {
  1865. submitProblems(local_url$1);
  1866. }
  1867. submitCnt++;
  1868. });
  1869. m.observe(dom, {
  1870. childList: true,
  1871. attributes: true
  1872. });
  1873. }
  1874. function handler() {
  1875. loadID$1++;
  1876. let findSubmitButton = function(sel) {
  1877. if (!sel) return null;
  1878. return Array.from(document.querySelectorAll(sel && { length: 0 })).find((e) => {
  1879. return e && e.innerText == "提交解答" || e.innerText == "提交";
  1880. });
  1881. };
  1882. const isNext = !!document.querySelector("#__next");
  1883. submitbutton = findSubmitButton(isProblem(local_url$1) || isNext ? "" : ".question-detail-bottom .pull-right button");
  1884. if (!submitbutton) {
  1885. submitbutton = document.querySelector('[data-e2e-locator="console-submit-button"]');
  1886. }
  1887. if (submitbutton) {
  1888. watchDom(submitbutton);
  1889. submitbutton.addEventListener("click", () => {
  1890. submitProblems(local_url$1, 10 * 1e3);
  1891. });
  1892. } else if (loadID$1 < 10) {
  1893. setTimeout(() => {
  1894. handlerNotFound();
  1895. }, 3e3);
  1896. }
  1897. }
  1898. function watchSubmit() {
  1899. if (!isProblem()) {
  1900. return;
  1901. }
  1902. try {
  1903. if ((window == null ? void 0 : window.fetch) && (window == null ? void 0 : window.unsafeWindow)) {
  1904. let originalFetch = window == null ? void 0 : window.fetch;
  1905. window.unsafeWindow.fetch = function() {
  1906. return originalFetch.apply(this, arguments).then(function(response) {
  1907. let res = response.clone();
  1908. res.text().then(function(bodyText) {
  1909. let url = res.url;
  1910. if (isDev()) {
  1911. console.log("query result", bodyText);
  1912. }
  1913. if (!/https:\/\/leetcode\.(cn|com)\/submissions\/detail\/\d+\/check\/.*/.test(url)) {
  1914. return;
  1915. }
  1916. if (res.status == 200 && res.ok) {
  1917. let result = JSON.parse(bodyText);
  1918. const ID2 = getId(local_url$1);
  1919. const status = (result == null ? void 0 : result.status_msg) == "Accepted" ? "ac" : (result == null ? void 0 : result.status_msg) == "Wrong Answer" ? "notac" : "null";
  1920. watchSaveStatus(ID2, status);
  1921. }
  1922. const cache = Cache.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], true, Object.name);
  1923. if (cache[ID] == null || cache[Id] == void 0) {
  1924. submitProblems(local_url$1);
  1925. }
  1926. });
  1927. return response;
  1928. });
  1929. };
  1930. } else {
  1931. console.warn("浏览器当前环境不支持 unsafeWindow 将做兼容处理 ");
  1932. handler();
  1933. }
  1934. } catch (e) {
  1935. console.error(e);
  1936. }
  1937. }
  1938. const local_url = window.location.href;
  1939. const randomProblemKey = () => Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_random_problems_key__"]) == void 0 ? true : Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_random_problems_key__"]);
  1940. let Container = null;
  1941. Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_button_is_none__"], true, Boolean.name);
  1942. if (isProblem() || isLeetCodeCircleUrl()) {
  1943. const start = () => {
  1944. Container = document.createElement("div");
  1945. const body = document.querySelector("body");
  1946. body.append(Container);
  1947. Container.style.display = "block";
  1948. return Container;
  1949. };
  1950. let dom = start();
  1951. const VueApp = vue.createApp(App);
  1952. VueApp.use(ElementPlus).mount(dom);
  1953. }
  1954. if (isProblem() || isLeetCodeCircleUrl()) {
  1955. _GM_registerMenuCommand(`随机一道题 ☕`, randomProblem, { title: "随机一道题目,你可以通过ctrl+atl+j显示一道题目" });
  1956. _GM_registerMenuCommand(`${randomProblemKey() ? "关闭" : "启用"} 随机题目快捷键 ☕`, () => {
  1957. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_random_problems_key__"], !randomProblemKey());
  1958. window.location.reload();
  1959. }, { title: "该功能是随机一道题的快捷键,你可以通过ctrl+atl+j显示一道题目" });
  1960. if (isLeetCodeCircleUrl()) {
  1961. installEnglishLinkChangeCommand();
  1962. }
  1963. if (randomProblemKey()) {
  1964. document.addEventListener("keydown", async function(event) {
  1965. if (event.ctrlKey && event.altKey && event.key === "j") {
  1966. randomProblem();
  1967. }
  1968. });
  1969. }
  1970. }
  1971. let loadID = 0;
  1972. async function run() {
  1973. loadID++;
  1974. if (isProblem(local_url)) {
  1975. await sleep(3e3);
  1976. if (isProblem(local_url) && loadID == 1) {
  1977. submitProblems(local_url);
  1978. }
  1979. } else if (isLeetCodeCircleUrl(local_url)) {
  1980. _GM_registerMenuCommand(`安装到${install_pos() ? "右侧" : "左侧"} 🎁`, () => {
  1981. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_insert_pos__"], install_pos());
  1982. window.location.reload();
  1983. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  1984. _GM_registerMenuCommand(`清空题目状态缓存 🚀`, () => {
  1985. Message("确认清空题目状态缓存", () => {
  1986. deleteAllACCountKeys();
  1987. window.location.reload();
  1988. });
  1989. }, { title: "如果题目状态出现问题,可以试试,一般情况下不建议使用" });
  1990. _GM_registerMenuCommand(`同步题目状态 🚀`, () => {
  1991. Message("确认同步题目状态", async () => {
  1992. await addProcess(true, void 0, true);
  1993. });
  1994. }, { title: "如果不在同一个浏览器答题,会出现ac题目状态没有及时同步,可以使用此功能" });
  1995. _GM_registerMenuCommand(`${initObj().onlyUrls ? "仅在收藏题单页面生效" : "所有题单生效"}`, () => {
  1996. const u = initObj();
  1997. u.onlyUrls = !u.onlyUrls;
  1998. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"], u);
  1999. }, { title: "插件默认会在所有讨论发布页生效,如果只想在收藏链接生效,可以使用此功能" });
  2000. _GM_registerMenuCommand(`添加本页`, () => {
  2001. const urls = initUrls();
  2002. let ok = false;
  2003. let url = window.location.href;
  2004. for (let info of urls) {
  2005. if (!info || !(info == null ? void 0 : info.link)) {
  2006. continue;
  2007. }
  2008. if (info.link.indexOf(url) != -1) {
  2009. ok = true;
  2010. break;
  2011. }
  2012. }
  2013. if (ok) {
  2014. ElementPlus.ElMessage({
  2015. message: "收藏失败,链接已经存在!",
  2016. type: "error"
  2017. });
  2018. } else {
  2019. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  2020. try {
  2021. url = url.split("view")[0];
  2022. } catch (e) {
  2023. url = window.location.href;
  2024. }
  2025. }
  2026. urls.unshift({
  2027. title: document.title,
  2028. link: url
  2029. });
  2030. Container.style.display = "block";
  2031. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], urls);
  2032. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_update__"], true);
  2033. Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_add_cur__"], true);
  2034. ElementPlus.ElMessage({
  2035. message: "收藏成功!刷新生效",
  2036. type: "success"
  2037. });
  2038. }
  2039. });
  2040. }
  2041. }
  2042. tips_message();
  2043. watchSubmit();
  2044. run();
  2045. startStopRanking();
  2046.  
  2047. })(ElementPlus, Vue);