0x3f-problem-solution

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

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

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