0x3f-problem-solution

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

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

  1. // ==UserScript==
  2. // @name 0x3f-problem-solution
  3. // @namespace https://gf.qytechs.cn/zh-CN/scripts/501134-0x3f-problem-solution
  4. // @version 0.0.4.5
  5. // @author wuxin0011
  6. // @description 自定义分数区间显示题目 标记题目状态 配合灵茶山艾府题单解题
  7. // @license MIT
  8. // @icon https://assets.leetcode.cn/aliyun-lc-upload/users/endlesscheng/avatar_1690721039.png
  9. // @source https://github.com/wuxin0011/tampermonkey-script/tree/main/0x3f-leetcode
  10. // @supportURL https://gf.qytechs.cn/zh-CN/scripts/501134-0x3f-problem-solution/feedback
  11. // @match https://leetcode.cn/circle/discuss/*
  12. // @match https://leetcode.cn/problems/*
  13. // @match https://leetcode.cn/contest/weekly-contest-*/problems/*
  14. // @match https://leetcode.cn/contest/biweekly-contest-*/problems/*
  15. // @require https://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-f382fe90]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-f382fe90]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-f382fe90]{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. console.log("saveUrls", saveUrls);
  322. for (let i = 0, u = null; Array.isArray(saveUrls) && i < saveUrls.length; i++) {
  323. try {
  324. u = saveUrls[i];
  325. if (!u || !(u == null ? void 0 : u.link)) continue;
  326. let s = Object.values(u).join("");
  327. if (s == "null" || !Cache$1.get(u.link) || !getAcCountKey(u.link) || !Cache$1.get(getAcCountKey(u.link))) {
  328. continue;
  329. }
  330. let o = Cache$1.get(getAcCountKey(u.link));
  331. u["ac"] = isNaN(o["ac"]) ? 0 : parseInt(o["ac"]);
  332. u["tot"] = isNaN(o["tot"]) ? 0 : parseInt(o["tot"]);
  333. } catch (e) {
  334. }
  335. infos.push(Object.assign({}, u));
  336. }
  337. return infos;
  338. }
  339. const initUrls = () => {
  340. 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;
  341. return computeAcInfo(saveUrls);
  342. };
  343. const initObj = () => Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"]) ? Object.assign(defaultObj, Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"])) : defaultObj;
  344. const support_plugins = () => {
  345. const u = initObj();
  346. if (!u || !u.onlyUrls) return true;
  347. let url = window.location.href;
  348. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  349. try {
  350. url = url.split("view")[0];
  351. } catch (e) {
  352. url = window.location.href;
  353. }
  354. }
  355. const urls = initUrls();
  356. for (let info of urls) {
  357. if (!info || !(info == null ? void 0 : info.link)) {
  358. continue;
  359. }
  360. if (info.link.indexOf(url) != -1) {
  361. return true;
  362. }
  363. }
  364. return false;
  365. };
  366. const defaultUrls = [
  367. {
  368. title: "字符串(KMP/Z函数/Manacher/字符串哈希/AC自动机/后缀数组/子序列自动机)",
  369. link: "https://leetcode.cn/circle/discuss/SJFwQI/",
  370. cnt: 0,
  371. ac: 0
  372. },
  373. {
  374. title: "链表、二叉树与一般树(前后指针/快慢指针/DFS/BFS/直径/LCA)",
  375. link: "https://leetcode.cn/circle/discuss/K0n2gO/",
  376. cnt: 0,
  377. ac: 0
  378. },
  379. {
  380. title: "贪心算法(基本贪心策略/反悔/区间/字典序/数学/思维/构造)",
  381. link: "https://leetcode.cn/circle/discuss/g6KTKL/",
  382. cnt: 0,
  383. ac: 0
  384. },
  385. {
  386. title: "滑动窗口(定长/不定长/多指针)",
  387. link: "https://leetcode.cn/circle/discuss/0viNMK/"
  388. },
  389. {
  390. title: "二分算法(二分答案/最小化最大值/最大化最小值/第K小)",
  391. link: "https://leetcode.cn/circle/discuss/SqopEo/",
  392. cnt: 0,
  393. ac: 0
  394. },
  395. {
  396. title: "单调栈(矩形面积/贡献法/最小字典序)",
  397. link: "https://leetcode.cn/circle/discuss/9oZFK9/",
  398. cnt: 0,
  399. ac: 0
  400. },
  401. {
  402. title: "网格图(DFS/BFS/综合应用)",
  403. link: "https://leetcode.cn/circle/discuss/YiXPXW/",
  404. cnt: 0,
  405. ac: 0
  406. },
  407. {
  408. title: "位运算(基础/性质/拆位/试填/恒等式/贪心/脑筋急转弯)",
  409. link: "https://leetcode.cn/circle/discuss/dHn9Vk/",
  410. cnt: 0,
  411. ac: 0
  412. },
  413. {
  414. title: "图论算法(DFS/BFS/拓扑排序/最短路/最小生成树/二分图/基环树/欧拉路径)",
  415. link: "https://leetcode.cn/circle/discuss/01LUak/",
  416. cnt: 0,
  417. ac: 0
  418. },
  419. {
  420. title: "动态规划(入门/背包/状态机/划分/区间/状压/数位/树形/数据结构优化)",
  421. link: "https://leetcode.cn/circle/discuss/tXLS3i/",
  422. cnt: 0,
  423. ac: 0
  424. },
  425. {
  426. title: "常用数据结构(前缀和/差分/栈/队列/堆/字典树/并查集/树状数组/线段树)",
  427. link: "https://leetcode.cn/circle/discuss/mOr1u6/",
  428. cnt: 0,
  429. ac: 0
  430. },
  431. {
  432. title: "数学算法(数论/组合/概率期望/博弈/计算几何/随机算法)",
  433. link: "https://leetcode.cn/circle/discuss/IYT3ss/",
  434. cnt: 0,
  435. ac: 0
  436. }
  437. ];
  438. function getId(problemUrl) {
  439. if (isContest(problemUrl) || isProblem(problemUrl)) {
  440. try {
  441. return problemUrl.split("problems")[1].split("/")[1];
  442. } catch (e) {
  443. return "";
  444. }
  445. }
  446. return "";
  447. }
  448. function postData(ID) {
  449. return {
  450. "query": "\n query userQuestionStatus($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n status\n }\n}\n ",
  451. "variables": {
  452. "titleSlug": ID
  453. },
  454. "operationName": "userQuestionStatus"
  455. };
  456. }
  457. function queryStatus(ID = "", cache = {}, cur = void 0, watch2 = false) {
  458. if (!ID) {
  459. return;
  460. }
  461. if (cache[ID] == void 0 || cache[ID] != STATUS["AC"]) {
  462. fetch("https://leetcode.cn/graphql/", {
  463. method: "POST",
  464. credentials: "include",
  465. headers: {
  466. "Content-Type": "application/json"
  467. },
  468. body: JSON.stringify(postData(ID))
  469. }).then((res) => res.json()).then((response) => {
  470. var _a, _b, _c;
  471. if ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.question) {
  472. const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status;
  473. if (cache[ID] == void 0 || cache[ID] != status) {
  474. cache[ID] = status == null ? "null" : status;
  475. if (watch2) {
  476. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], cache);
  477. window.localStorage.setItem(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_status_update__"], JSON.stringify({
  478. "id": ID,
  479. "status": cache[ID]
  480. }));
  481. }
  482. createStatus(cache[ID], cur);
  483. }
  484. } else {
  485. console.log("query result is undefined");
  486. }
  487. }).catch((ignore) => {
  488. console.error("query status error : ", ignore);
  489. });
  490. }
  491. }
  492. function addProcess(reload = true, doms = void 0, asyncAc = false) {
  493. var _a;
  494. let problems_doms = Array.isArray(doms) ? doms : loadProblems();
  495. const cache = getLocalProblemStatus();
  496. for (let i = 0; i < problems_doms.length; i++) {
  497. let cur = problems_doms[i].parentElement;
  498. if (!(cur instanceof HTMLElement)) {
  499. continue;
  500. }
  501. const ID = getId((_a = problems_doms[i]) == null ? void 0 : _a.href);
  502. if (!ID) {
  503. continue;
  504. }
  505. if (install_pos()) {
  506. cur.style.listStyleType = "none";
  507. }
  508. if (!cache[ID] || cache[ID] != STATUS["AC"] && asyncAc) {
  509. queryStatus(ID, cache, cur, false);
  510. } else {
  511. let status = cache[ID];
  512. createStatus(status, cur);
  513. }
  514. }
  515. if (reload) {
  516. let cnt = 10;
  517. let timeId = setInterval(() => {
  518. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], cache);
  519. cnt--;
  520. if (cnt == 0) {
  521. window.clearInterval(timeId);
  522. }
  523. }, 3e3);
  524. }
  525. }
  526. const submitProblems = (url = window.location.href, timeout = 500) => {
  527. const ID = getId(url);
  528. if (!ID) {
  529. return;
  530. }
  531. setTimeout(() => {
  532. const cache = getLocalProblemStatus();
  533. queryStatus(ID, cache, void 0, true);
  534. }, timeout);
  535. };
  536. const watchLinkStatusUpdate = (e) => {
  537. var _a;
  538. if (e.key != __0X3F_PROBLEM_KEYS__["__0x3f_problmes_status_update__"]) {
  539. return;
  540. }
  541. let { id, status } = JSON.parse(e.newValue);
  542. if (!id || !status) {
  543. return;
  544. }
  545. let thisLink = `https://leetcode.cn/problems/${id}`;
  546. let link = document.querySelector(`${linkCssSelector}[href^="https://leetcode.cn/problems/${id}"]`);
  547. if (!link || !(link == null ? void 0 : link.parentElement)) {
  548. let doms = loadProblems();
  549. for (let i = 0; i < doms.length; i++) {
  550. if (!doms[i] || !((_a = doms[i]) == null ? void 0 : _a.parentElement)) {
  551. continue;
  552. }
  553. if (doms[i].href.indexOf(thisLink) != -1) {
  554. link = doms[i];
  555. break;
  556. }
  557. }
  558. }
  559. createStatus(status, link);
  560. };
  561. function getAcCountKey(k) {
  562. if (!k) return "";
  563. return `0x3f_ac_key_${k}`;
  564. }
  565. function getProcess() {
  566. loadProblems();
  567. const cache = getLocalProblemStatus();
  568. let cnt = 0;
  569. for (let i = 0; i < A.length; i++) {
  570. let ID = getId(A[i].href);
  571. if (ID && cache[ID] == STATUS["AC"]) {
  572. cnt++;
  573. }
  574. }
  575. let url = window.location.href;
  576. Cache$1.set(getAcCountKey(url), { "tot": A.length, "ac": cnt });
  577. return [cnt, A.length];
  578. }
  579. function getLocalProblemStatus() {
  580. return Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"], true, Object.name);
  581. }
  582. const _hoisted_1 = { class: "processs-flex" };
  583. const _hoisted_2 = { style: { "text-align": "center", "color": "#121212" } };
  584. const _hoisted_3 = { class: "dialog-footer" };
  585. const formLabelWidth = "44px";
  586. const _sfc_main = {
  587. __name: "App",
  588. setup(__props) {
  589. let tableData = vue.reactive(initUrls());
  590. const keywords = vue.ref("");
  591. const dialogTableVisible = vue.ref(false);
  592. let urlsData = vue.computed(() => {
  593. let infos = computeAcInfo(tableData, false);
  594. let tot = 0, ac = 0;
  595. for (let info2 of infos) {
  596. if (info2["ac"] && info2["tot"]) {
  597. tot += info2["tot"];
  598. ac += info2["ac"];
  599. }
  600. }
  601. infos.unshift({ "title": "灵茶题单完成情况", "link": "https://leetcode.cn/u/endlesscheng/", "tot": tot, "ac": ac });
  602. return infos;
  603. });
  604. const isDisabbled = vue.computed(() => !!tableData.find((v) => (v == null ? void 0 : v.link) && (v == null ? void 0 : v.link.indexOf(window.location.href)) != -1));
  605. const dialogFormVisible = vue.ref(false);
  606. let totProblem = vue.ref(0);
  607. let finishProblem = vue.ref(0);
  608. const drawer = vue.ref(false);
  609. const viewSetting = () => {
  610. drawer.value = !drawer.value;
  611. let [cur, tot] = getProcess();
  612. finishProblem.value = cur;
  613. totProblem.value = tot;
  614. let url = window.location.href;
  615. let pos = tableData.findIndex((u) => !!u && u.link && u.link.indexOf(url) != -1);
  616. if (url && pos != -1 && tableData[pos]) {
  617. tableData[pos]["ac"] = cur;
  618. tableData[pos]["tot"] = tot;
  619. }
  620. };
  621. const computeProcess = (ac = 0, tot = 0) => {
  622. if (isNaN(ac) || isNaN(tot)) return 0;
  623. if (tot == 0) return 0;
  624. let p = 0;
  625. try {
  626. const s = String(ac / tot);
  627. let x1 = s.split(".")[1].padEnd(3).substring(0, 3);
  628. p = Math.min(100, Number(x1) / 10);
  629. } catch (e) {
  630. p = (ac / tot).toFixed(3) * 100;
  631. }
  632. return isNaN(p) ? 0 : p;
  633. };
  634. const finishProcess = vue.computed(() => computeProcess(finishProblem.value, totProblem.value));
  635. const processColors = [
  636. { color: "#f56c6c", percentage: 20 },
  637. { color: "#1989fa", percentage: 40 },
  638. { color: "#e6a23c", percentage: 60 },
  639. { color: "#6f7ad3", percentage: 80 },
  640. { color: "#5cb87a", percentage: 100 }
  641. ];
  642. const fromData = vue.reactive(initObj());
  643. vue.watch(fromData, () => {
  644. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  645. });
  646. const info = vue.reactive({
  647. title: "",
  648. link: "",
  649. status: "add"
  650. });
  651. const addlocal = () => {
  652. if (!isDisabbled) {
  653. return;
  654. }
  655. let [cur, tot] = getProcess();
  656. tableData.unshift({ title: document.title, link: window.location.href, "ac": cur, "tot": tot });
  657. };
  658. const updateIndex = vue.ref(-1);
  659. const showProblems = () => {
  660. dialogTableVisible.value = true;
  661. let o = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"]) == "true" || Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"]) == true;
  662. if (o) {
  663. addlocal();
  664. }
  665. };
  666. const handlerProblems = (status, updateInfo = { title: "", link: "" }, index = -1) => {
  667. dialogFormVisible.value = true;
  668. info.status = status;
  669. updateIndex.value = index;
  670. Object.assign(info, updateInfo);
  671. };
  672. const handlerMessage = (u, title, link) => {
  673. const a = u ? "添加" : "修改";
  674. const error = !title || !/https?:\/\/.*/.test(link);
  675. if (error) {
  676. ElementPlus.ElMessage.error(`${a} 失败 请保证标题或者链接有效 `);
  677. } else {
  678. ElementPlus.ElMessage.success(`${a} 成功 `);
  679. }
  680. return !error;
  681. };
  682. const addOrUpdate = () => {
  683. if (!handlerMessage(info.status == "add", info.title, info.link)) {
  684. return;
  685. }
  686. if (info.status == "add") {
  687. tableData.unshift({ title: info.title, link: info.link, "ac": 0, "tot": 0 });
  688. } else {
  689. let index = updateIndex.value;
  690. if (index != -1 && index < tableData.length) {
  691. tableData[index].link = info.link;
  692. tableData[index].title = info.title;
  693. }
  694. }
  695. dialogFormVisible.value = false;
  696. };
  697. const deleteProblems = (index) => {
  698. tableData.splice(index, 1);
  699. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData));
  700. };
  701. const handlerDefault = () => {
  702. Message("确认使用默认题单,将会重置题单", () => {
  703. for (let i = 0; i < tableData.length; i++) {
  704. delete tableData[i];
  705. }
  706. let infos = computeAcInfo(defaultUrls);
  707. for (let item of infos) {
  708. tableData.unshift(item);
  709. }
  710. ElementPlus.ElMessage({
  711. type: "success",
  712. message: "重置成功"
  713. });
  714. });
  715. };
  716. const asyncLocalStatus = () => {
  717. Message("确认同步题单", () => {
  718. addProcess(true, void 0, true);
  719. });
  720. };
  721. window.addEventListener("beforeunload", () => {
  722. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], vue.toRaw(tableData).filter((u) => u != null && u != void 0));
  723. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true);
  724. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"], false);
  725. });
  726. vue.onMounted(() => {
  727. if (support_plugins()) {
  728. let times = 30;
  729. let loadTimeId = setInterval(() => {
  730. let a = queryProblem();
  731. times--;
  732. if (Array.isArray(a) && a.length > 0) {
  733. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  734. addProcess();
  735. window.clearInterval(loadTimeId);
  736. }
  737. if (times == 0) {
  738. window.clearInterval(loadTimeId);
  739. }
  740. }, 200);
  741. window.addEventListener("storage", (e) => {
  742. watchLinkStatusUpdate(e);
  743. });
  744. }
  745. });
  746. const q1 = vue.ref(false);
  747. const q2 = vue.ref(false);
  748. return (_ctx, _cache) => {
  749. const _component_el_button = vue.resolveComponent("el-button");
  750. const _component_el_progress = vue.resolveComponent("el-progress");
  751. const _component_el_divider = vue.resolveComponent("el-divider");
  752. const _component_el_input = vue.resolveComponent("el-input");
  753. const _component_el_col = vue.resolveComponent("el-col");
  754. const _component_el_form_item = vue.resolveComponent("el-form-item");
  755. const _component_el_switch = vue.resolveComponent("el-switch");
  756. const _component_el_tooltip = vue.resolveComponent("el-tooltip");
  757. const _component_el_form = vue.resolveComponent("el-form");
  758. const _component_el_dialog = vue.resolveComponent("el-dialog");
  759. const _component_el_row = vue.resolveComponent("el-row");
  760. const _component_el_link = vue.resolveComponent("el-link");
  761. const _component_el_table_column = vue.resolveComponent("el-table-column");
  762. const _component_el_table = vue.resolveComponent("el-table");
  763. const _component_el_drawer = vue.resolveComponent("el-drawer");
  764. return vue.openBlock(), vue.createElementBlock("div", null, [
  765. vue.createVNode(_component_el_button, {
  766. type: "primary",
  767. style: {},
  768. onClick: viewSetting,
  769. class: "m-setting-button m-button",
  770. circle: "",
  771. size: "large"
  772. }, {
  773. default: vue.withCtx(() => [
  774. vue.createTextVNode(" 0X3F ")
  775. ]),
  776. _: 1
  777. }),
  778. vue.createVNode(_component_el_drawer, {
  779. modelValue: drawer.value,
  780. "onUpdate:modelValue": _cache[19] || (_cache[19] = ($event) => drawer.value = $event),
  781. size: "30%",
  782. "with-header": false,
  783. style: { "position": "fixed !important" },
  784. direction: "rtl"
  785. }, {
  786. default: vue.withCtx(() => [
  787. vue.createElementVNode("div", _hoisted_1, [
  788. vue.createVNode(_component_el_progress, {
  789. type: "circle",
  790. percentage: finishProcess.value,
  791. color: processColors
  792. }, {
  793. default: vue.withCtx(({ percentage }) => [
  794. vue.createElementVNode("p", null, vue.toDisplayString(percentage) + "%", 1)
  795. ]),
  796. _: 1
  797. }, 8, ["percentage"])
  798. ]),
  799. vue.createElementVNode("p", _hoisted_2, vue.toDisplayString(vue.unref(finishProblem)) + " / " + vue.toDisplayString(vue.unref(totProblem)), 1),
  800. vue.createCommentVNode("", true),
  801. vue.createVNode(_component_el_divider),
  802. vue.createVNode(_component_el_form, {
  803. "label-position": "left",
  804. "label-width": "auto",
  805. model: fromData,
  806. style: { "max-width": "600px" }
  807. }, {
  808. default: vue.withCtx(() => [
  809. vue.createVNode(_component_el_form_item, { label: "分数区间" }, {
  810. default: vue.withCtx(() => [
  811. vue.createVNode(_component_el_col, { span: 10 }, {
  812. default: vue.withCtx(() => [
  813. vue.createVNode(_component_el_input, {
  814. modelValue: fromData.min,
  815. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => fromData.min = $event),
  816. "aria-placeholder": "",
  817. placeholder: " min "
  818. }, null, 8, ["modelValue"])
  819. ]),
  820. _: 1
  821. }),
  822. vue.createVNode(_component_el_col, {
  823. class: "text-center",
  824. span: 1,
  825. style: { "margin": "0 0.5rem" }
  826. }, {
  827. default: vue.withCtx(() => [
  828. vue.createTextVNode("-")
  829. ]),
  830. _: 1
  831. }),
  832. vue.createVNode(_component_el_col, { span: 10 }, {
  833. default: vue.withCtx(() => [
  834. vue.createVNode(_component_el_input, {
  835. modelValue: fromData.max,
  836. "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => fromData.max = $event),
  837. "aria-placeholder": "",
  838. placeholder: " max"
  839. }, null, 8, ["modelValue"])
  840. ]),
  841. _: 1
  842. })
  843. ]),
  844. _: 1
  845. }),
  846. vue.createVNode(_component_el_form_item, { label: "显示会员题" }, {
  847. default: vue.withCtx(() => [
  848. vue.createVNode(_component_el_switch, {
  849. modelValue: fromData.visiableMember,
  850. "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => fromData.visiableMember = $event)
  851. }, null, 8, ["modelValue"])
  852. ]),
  853. _: 1
  854. }),
  855. vue.createVNode(_component_el_form_item, { label: "隐藏AC题目" }, {
  856. default: vue.withCtx(() => [
  857. vue.createVNode(_component_el_switch, {
  858. modelValue: fromData.hiddenAc,
  859. "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => fromData.hiddenAc = $event)
  860. }, null, 8, ["modelValue"])
  861. ]),
  862. _: 1
  863. }),
  864. vue.createVNode(_component_el_form_item, { label: "收藏题单中生效" }, {
  865. default: vue.withCtx(() => [
  866. vue.createVNode(_component_el_tooltip, {
  867. content: "插件只在收藏题单中生效,刷新生效 ",
  868. placement: "bottom-end"
  869. }, {
  870. default: vue.withCtx(() => [
  871. vue.createVNode(_component_el_switch, {
  872. modelValue: fromData.onlyUrls,
  873. "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => fromData.onlyUrls = $event)
  874. }, null, 8, ["modelValue"])
  875. ]),
  876. _: 1
  877. })
  878. ]),
  879. _: 1
  880. }),
  881. vue.createVNode(_component_el_form_item, { label: "使用题单" }, {
  882. default: vue.withCtx(() => [
  883. vue.createVNode(_component_el_switch, {
  884. modelValue: fromData.useDefaultSetting,
  885. "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => fromData.useDefaultSetting = $event)
  886. }, null, 8, ["modelValue"])
  887. ]),
  888. _: 1
  889. })
  890. ]),
  891. _: 1
  892. }, 8, ["model"]),
  893. fromData.useDefaultSetting ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
  894. vue.createVNode(_component_el_divider),
  895. vue.createVNode(_component_el_button, {
  896. plain: "",
  897. onClick: asyncLocalStatus
  898. }, {
  899. default: vue.withCtx(() => [
  900. vue.createTextVNode(" 同步本页题目状态 ")
  901. ]),
  902. _: 1
  903. }),
  904. vue.createVNode(_component_el_button, {
  905. plain: "",
  906. onClick: showProblems
  907. }, {
  908. default: vue.withCtx(() => [
  909. vue.createTextVNode(" 查看收藏的题单 ")
  910. ]),
  911. _: 1
  912. }),
  913. vue.createVNode(_component_el_divider)
  914. ], 64)) : vue.createCommentVNode("", true),
  915. vue.createVNode(_component_el_button, {
  916. plain: "",
  917. onClick: _cache[8] || (_cache[8] = ($event) => q1.value = !q1.value)
  918. }, {
  919. default: vue.withCtx(() => [
  920. vue.createTextVNode(" 问题1 ")
  921. ]),
  922. _: 1
  923. }),
  924. vue.createVNode(_component_el_tooltip, { content: "此功能是为了多刷题单,重置题目状态,敬请期待!" }, {
  925. default: vue.withCtx(() => [
  926. vue.createVNode(_component_el_button, {
  927. plain: "",
  928. type: "warning",
  929. disabled: true
  930. }, {
  931. default: vue.withCtx(() => [
  932. vue.createTextVNode(" 题单重置 ")
  933. ]),
  934. _: 1
  935. })
  936. ]),
  937. _: 1
  938. }),
  939. vue.createVNode(_component_el_dialog, {
  940. modelValue: q1.value,
  941. "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => q1.value = $event),
  942. title: "关于查询状态会不会被封号 ?"
  943. }, {
  944. default: vue.withCtx(() => [
  945. vue.createVNode(Q1)
  946. ]),
  947. _: 1
  948. }, 8, ["modelValue"]),
  949. vue.createVNode(_component_el_dialog, {
  950. modelValue: q2.value,
  951. "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => q2.value = $event),
  952. title: "相关问题 ?"
  953. }, {
  954. default: vue.withCtx(() => [
  955. vue.createVNode(Q2)
  956. ]),
  957. _: 1
  958. }, 8, ["modelValue"]),
  959. vue.createVNode(_component_el_dialog, {
  960. modelValue: dialogTableVisible.value,
  961. "onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => dialogTableVisible.value = $event),
  962. title: "题单"
  963. }, {
  964. default: vue.withCtx(() => [
  965. vue.createVNode(_component_el_row, { gutter: 10 }, {
  966. default: vue.withCtx(() => [
  967. vue.createVNode(_component_el_col, { span: 8 }, {
  968. default: vue.withCtx(() => [
  969. vue.createVNode(_component_el_input, {
  970. modelValue: keywords.value,
  971. "onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => keywords.value = $event),
  972. placeholder: "请输入关键词过滤",
  973. clearable: ""
  974. }, null, 8, ["modelValue"])
  975. ]),
  976. _: 1
  977. }),
  978. vue.createVNode(_component_el_col, { span: 16 }, {
  979. default: vue.withCtx(() => [
  980. vue.createVNode(_component_el_button, {
  981. plain: "",
  982. onClick: addlocal,
  983. disabled: isDisabbled.value
  984. }, {
  985. default: vue.withCtx(() => [
  986. vue.createTextVNode(" 添加本页 ")
  987. ]),
  988. _: 1
  989. }, 8, ["disabled"]),
  990. vue.createVNode(_component_el_button, {
  991. plain: "",
  992. onClick: _cache[12] || (_cache[12] = ($event) => handlerProblems("add"))
  993. }, {
  994. default: vue.withCtx(() => [
  995. vue.createTextVNode(" 自定义 ")
  996. ]),
  997. _: 1
  998. }),
  999. vue.createVNode(_component_el_button, {
  1000. plain: "",
  1001. onClick: handlerDefault
  1002. }, {
  1003. default: vue.withCtx(() => [
  1004. vue.createTextVNode(" 默认 ")
  1005. ]),
  1006. _: 1
  1007. }),
  1008. vue.createVNode(_component_el_button, {
  1009. plain: "",
  1010. onClick: _cache[13] || (_cache[13] = ($event) => q2.value = !q2.value)
  1011. }, {
  1012. default: vue.withCtx(() => [
  1013. vue.createTextVNode(" 相关问题 ")
  1014. ]),
  1015. _: 1
  1016. })
  1017. ]),
  1018. _: 1
  1019. })
  1020. ]),
  1021. _: 1
  1022. }),
  1023. vue.createVNode(_component_el_table, {
  1024. data: vue.unref(urlsData),
  1025. height: "300",
  1026. style: { "width": "100%", "margin-top": "10px" }
  1027. }, {
  1028. default: vue.withCtx(() => [
  1029. vue.createVNode(_component_el_table_column, {
  1030. label: "标题",
  1031. width: "auto",
  1032. align: "center"
  1033. }, {
  1034. default: vue.withCtx((scope) => [
  1035. vue.createVNode(_component_el_link, {
  1036. disabled: scope.row.link == "https://leetcode.cn/u/endlesscheng/",
  1037. href: scope.row.link,
  1038. target: "_blank",
  1039. type: "default"
  1040. }, {
  1041. default: vue.withCtx(() => [
  1042. vue.createTextVNode(vue.toDisplayString(scope.row.title), 1)
  1043. ]),
  1044. _: 2
  1045. }, 1032, ["disabled", "href"])
  1046. ]),
  1047. _: 1
  1048. }),
  1049. vue.createVNode(_component_el_table_column, {
  1050. label: "AC",
  1051. width: "80",
  1052. align: "center"
  1053. }, {
  1054. default: vue.withCtx((scope) => [
  1055. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.ac) ? 0 : scope.row.ac), 1)
  1056. ]),
  1057. _: 1
  1058. }),
  1059. vue.createVNode(_component_el_table_column, {
  1060. label: "Total",
  1061. width: "80",
  1062. align: "center"
  1063. }, {
  1064. default: vue.withCtx((scope) => [
  1065. vue.createTextVNode(vue.toDisplayString(isNaN(scope.row.tot) ? 0 : scope.row.tot), 1)
  1066. ]),
  1067. _: 1
  1068. }),
  1069. vue.createVNode(_component_el_table_column, {
  1070. label: "process",
  1071. width: "80",
  1072. align: "center"
  1073. }, {
  1074. default: vue.withCtx((scope) => {
  1075. var _a, _b, _c;
  1076. return [
  1077. 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)
  1078. ];
  1079. }),
  1080. _: 1
  1081. }),
  1082. vue.createVNode(_component_el_table_column, {
  1083. label: "操作",
  1084. width: "150",
  1085. align: "center"
  1086. }, {
  1087. default: vue.withCtx((scope) => [
  1088. vue.createVNode(_component_el_button, {
  1089. type: "primary",
  1090. size: "small",
  1091. disabled: scope.row.link == "https://leetcode.cn/u/endlesscheng/",
  1092. onClick: ($event) => handlerProblems("update", scope.row, scope.$index)
  1093. }, {
  1094. default: vue.withCtx(() => [
  1095. vue.createTextVNode("编辑")
  1096. ]),
  1097. _: 2
  1098. }, 1032, ["disabled", "onClick"]),
  1099. vue.createVNode(_component_el_button, {
  1100. disabled: scope.row.link == "https://leetcode.cn/u/endlesscheng/",
  1101. type: "danger",
  1102. size: "small",
  1103. onClick: ($event) => deleteProblems(scope.$index)
  1104. }, {
  1105. default: vue.withCtx(() => [
  1106. vue.createTextVNode("删除")
  1107. ]),
  1108. _: 2
  1109. }, 1032, ["disabled", "onClick"])
  1110. ]),
  1111. _: 1
  1112. })
  1113. ]),
  1114. _: 1
  1115. }, 8, ["data"])
  1116. ]),
  1117. _: 1
  1118. }, 8, ["modelValue"]),
  1119. vue.createVNode(_component_el_dialog, {
  1120. modelValue: dialogFormVisible.value,
  1121. "onUpdate:modelValue": _cache[18] || (_cache[18] = ($event) => dialogFormVisible.value = $event),
  1122. title: `${info.status == "add" ? "添加" : "编辑"}`,
  1123. width: "400"
  1124. }, {
  1125. footer: vue.withCtx(() => [
  1126. vue.createElementVNode("div", _hoisted_3, [
  1127. vue.createVNode(_component_el_button, {
  1128. onClick: _cache[17] || (_cache[17] = ($event) => dialogFormVisible.value = false)
  1129. }, {
  1130. default: vue.withCtx(() => [
  1131. vue.createTextVNode("取消")
  1132. ]),
  1133. _: 1
  1134. }),
  1135. vue.createVNode(_component_el_button, {
  1136. type: "primary",
  1137. onClick: addOrUpdate
  1138. }, {
  1139. default: vue.withCtx(() => [
  1140. vue.createTextVNode(" 确认 ")
  1141. ]),
  1142. _: 1
  1143. })
  1144. ])
  1145. ]),
  1146. default: vue.withCtx(() => [
  1147. vue.createVNode(_component_el_form, null, {
  1148. default: vue.withCtx(() => [
  1149. vue.createVNode(_component_el_form_item, {
  1150. label: "标题",
  1151. "label-width": formLabelWidth
  1152. }, {
  1153. default: vue.withCtx(() => [
  1154. vue.createVNode(_component_el_input, {
  1155. modelValue: info.title,
  1156. "onUpdate:modelValue": _cache[15] || (_cache[15] = ($event) => info.title = $event),
  1157. autocomplete: "off"
  1158. }, null, 8, ["modelValue"])
  1159. ]),
  1160. _: 1
  1161. }),
  1162. vue.createVNode(_component_el_form_item, {
  1163. label: "链接",
  1164. "label-width": formLabelWidth
  1165. }, {
  1166. default: vue.withCtx(() => [
  1167. vue.createVNode(_component_el_input, {
  1168. modelValue: info.link,
  1169. "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => info.link = $event),
  1170. autocomplete: "off"
  1171. }, null, 8, ["modelValue"])
  1172. ]),
  1173. _: 1
  1174. })
  1175. ]),
  1176. _: 1
  1177. })
  1178. ]),
  1179. _: 1
  1180. }, 8, ["modelValue", "title"])
  1181. ]),
  1182. _: 1
  1183. }, 8, ["modelValue"])
  1184. ]);
  1185. };
  1186. }
  1187. };
  1188. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f382fe90"]]);
  1189. const cssLoader = (e) => {
  1190. const t = GM_getResourceText(e);
  1191. return GM_addStyle(t), t;
  1192. };
  1193. cssLoader("elementPlusCss");
  1194. const stopRankingKey = "__is_stop_rating_ranking__";
  1195. let conetstTimeId = null;
  1196. function run$1() {
  1197. const container = document.querySelector(".contest-question-info .list-group");
  1198. if (!container) return;
  1199. const ls = Array.from(container.querySelectorAll(".list-group-item .pull-right"));
  1200. for (let i = 0; i < 4; i++) {
  1201. if (i >= ls.length) {
  1202. break;
  1203. }
  1204. if (ls[i] instanceof HTMLElement) {
  1205. ls[i].textContent = "0";
  1206. }
  1207. }
  1208. window.clearInterval(conetstTimeId);
  1209. }
  1210. function startStopRanking() {
  1211. if (!isContest(window.location.href)) {
  1212. return;
  1213. }
  1214. const isNext = !!document.querySelector("#__next");
  1215. if (isNext) {
  1216. return;
  1217. }
  1218. const use = Cache$1.get(stopRankingKey);
  1219. if (use) {
  1220. conetstTimeId = setInterval(() => {
  1221. run$1();
  1222. }, 10);
  1223. }
  1224. _GM_registerMenuCommand(`${use ? "使用" : "关闭"} 排行榜`, () => {
  1225. Cache$1.set(stopRankingKey, !use);
  1226. window.location.reload();
  1227. }, { title: "对于不想看到排行榜的可以使用此功能 默认开启" });
  1228. }
  1229. const local_url = window.location.href;
  1230. let loadID = 0;
  1231. let submitCnt = 0;
  1232. function watchDom(dom) {
  1233. if (!(dom instanceof HTMLElement)) {
  1234. return;
  1235. }
  1236. let m = new MutationObserver(() => {
  1237. if (submitCnt % 2 == 1) {
  1238. submitProblems(local_url);
  1239. }
  1240. submitCnt++;
  1241. });
  1242. m.observe(dom, {
  1243. childList: true,
  1244. attributes: true
  1245. });
  1246. }
  1247. function run() {
  1248. loadID++;
  1249. if (isProblem(local_url) || isContest(local_url)) {
  1250. if (isProblem(local_url) && loadID == 1) {
  1251. submitProblems(local_url);
  1252. }
  1253. setTimeout(() => {
  1254. let submitbutton = null;
  1255. const isNext = !!document.querySelector("#__next");
  1256. if (isProblem(local_url) || isNext) {
  1257. submitbutton = document.querySelector("div [data-e2e-locator=console-submit-button]");
  1258. } else {
  1259. let buttons = Array.from(document.querySelectorAll(".question-detail-bottom .pull-right button"));
  1260. for (let i = buttons.length - 1; i >= 0; i--) {
  1261. if (buttons[i].textContent.indexOf("提交解答") != -1) {
  1262. submitbutton = buttons[i];
  1263. break;
  1264. }
  1265. }
  1266. }
  1267. if (submitbutton) {
  1268. submitbutton.addEventListener("click", () => {
  1269. submitProblems(local_url, 10 * 1e3);
  1270. });
  1271. watchDom(submitbutton);
  1272. } else if (loadID < 10) {
  1273. run();
  1274. }
  1275. }, 3e3);
  1276. } else if (isLeetCodeCircleUrl(local_url)) {
  1277. let Container = null;
  1278. let ok = Cache$1.get(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_button_is_none__"], true, Boolean.name);
  1279. const start = () => {
  1280. Container = document.createElement("div");
  1281. const body = document.querySelector("body");
  1282. body.append(Container);
  1283. Container.style.display = ok && support_plugins() ? "block" : "none";
  1284. return Container;
  1285. };
  1286. let dom = start();
  1287. const VueApp = vue.createApp(App);
  1288. _GM_registerMenuCommand(`${ok ? "隐藏按钮" : "显示按钮"}`, () => {
  1289. ok = !ok;
  1290. Container.style.display = ok ? "block" : "none";
  1291. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_button_is_none__"], ok);
  1292. }, { title: "可以手动关闭或者显示按钮 默认显示 刷新生效" });
  1293. _GM_registerMenuCommand(`安装到${install_pos() ? "右侧" : "左侧"}`, () => {
  1294. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_insert_pos__"], install_pos());
  1295. window.location.reload();
  1296. }, { title: "AC标记安装位置,默认左侧,刷新生效" });
  1297. _GM_registerMenuCommand(`清空题目状态缓存`, () => {
  1298. Message("确认清空题目状态缓存", () => {
  1299. Cache$1.remove(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_ac_key__"]);
  1300. window.location.reload();
  1301. });
  1302. }, { title: "如果题目状态出现问题,可以试试,一般情况下不建议使用" });
  1303. _GM_registerMenuCommand(`同步题目状态`, () => {
  1304. Message("确认同步题目状态", () => {
  1305. addProcess(true, void 0, true);
  1306. });
  1307. }, { title: "如果不在同一个浏览器答题,会出现ac题目状态没有及时同步,可以使用此功能" });
  1308. _GM_registerMenuCommand(`${initObj().onlyUrls ? "仅在收藏题单页面生效" : "所有题单生效"}`, () => {
  1309. const u = initObj();
  1310. u.onlyUrls = !u.onlyUrls;
  1311. Container.style.display = support_plugins() ? "block" : "none";
  1312. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_solution__"], u);
  1313. }, { title: "插件默认会在所有讨论发布页生效,如果只想在收藏链接生效,可以使用此功能" });
  1314. _GM_registerMenuCommand(`添加本页`, () => {
  1315. const urls = initUrls();
  1316. let ok2 = false;
  1317. let url = window.location.href;
  1318. for (let info of urls) {
  1319. if (!info || !(info == null ? void 0 : info.link)) {
  1320. continue;
  1321. }
  1322. if (info.link.indexOf(url) != -1) {
  1323. ok2 = true;
  1324. break;
  1325. }
  1326. }
  1327. if (ok2) {
  1328. ElementPlus.ElMessage({
  1329. message: "收藏失败,链接已经存在!",
  1330. type: "error"
  1331. });
  1332. } else {
  1333. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  1334. try {
  1335. url = url.split("view")[0];
  1336. } catch (e) {
  1337. url = window.location.href;
  1338. }
  1339. }
  1340. urls.unshift({
  1341. title: document.title,
  1342. link: url
  1343. });
  1344. Container.style.display = "block";
  1345. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_urls__"], urls);
  1346. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_update__"], true);
  1347. Cache$1.set(__0X3F_PROBLEM_KEYS__["__0x3f_problmes_add_cur__"], true);
  1348. ElementPlus.ElMessage({
  1349. message: "收藏成功!刷新生效",
  1350. type: "success"
  1351. });
  1352. }
  1353. });
  1354. VueApp.use(ElementPlus).mount(dom);
  1355. }
  1356. }
  1357. run();
  1358. startStopRanking();
  1359.  
  1360. })(Vue, ElementPlus);

QingJ © 2025

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