Greasy Fork is available in English.

0x3f-problem-solution

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

Ekde 2024/10/12. Vidu La ĝisdata versio.

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