0x3f-problem-solution

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址