0x3f-problem-solution

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

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

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

QingJ © 2025

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