0x3f-problem-solution

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

2024-10-13 기준 버전입니다. 최신 버전을 확인하세요.

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