0x3f-problem-solution

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

当前为 2024-11-11 提交的版本,查看 最新版本

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