0x3f-problem-solution

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

当前为 2024-07-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 0x3f-problem-solution
  3. // @namespace https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution
  4. // @version 0.0.4.1
  5. // @author wuxin0011
  6. // @description 自定义分数区间显示题目 标记题目状态 配合灵茶山艾府题单解题
  7. // @license MIT
  8. // @icon https://assets.leetcode.cn/aliyun-lc-upload/users/endlesscheng/avatar_1690721039.png
  9. // @source https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution
  10. // @match https://leetcode.cn/circle/discuss/*
  11. // @match https://leetcode.cn/problems/*
  12. // @match https://leetcode.cn/contest/weekly-contest-*/problems/*
  13. // @match https://leetcode.cn/contest/biweekly-contest-*/problems/*
  14. // @require https://cdn.jsdelivr.net/npm/vue@3.4.31/dist/vue.global.prod.js
  15. // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B
  16. // @require https://unpkg.com/element-plus@2.7.6/dist/index.full.js
  17. // @resource elementPlusCss https://unpkg.com/element-plus@2.7.6/dist/index.css
  18. // @grant GM_addStyle
  19. // @grant GM_deleteValue
  20. // @grant GM_getResourceText
  21. // @grant GM_getValue
  22. // @grant GM_registerMenuCommand
  23. // @grant GM_setValue
  24. // ==/UserScript==
  25.  
  26. (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const e=document.createElement("style");e.textContent=t,document.head.append(e)})(" .m-setting-button[data-v-feb4b33e]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-feb4b33e]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-feb4b33e]{display:flex;justify-content:center;align-items:center} ");
  27.  
  28. (function (vue, ElementPlus) {
  29. 'use strict';
  30.  
  31. var _GM_deleteValue = /* @__PURE__ */ (() => typeof GM_deleteValue != "undefined" ? GM_deleteValue : void 0)();
  32. var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
  33. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  34. var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
  35. class Cache {
  36. set(k, v) {
  37. _GM_setValue(k, v);
  38. }
  39. get(k, parse = true, name = String.name) {
  40. try {
  41. let v = _GM_getValue(k);
  42. switch (name) {
  43. case String.name:
  44. if (v == null) {
  45. return "null";
  46. }
  47. return v;
  48. case Object.name:
  49. if (v == null || v == void 0 || typeof v != "object") {
  50. return {};
  51. }
  52. return v;
  53. case Boolean.name:
  54. if (v === null || v == void 0) {
  55. return false;
  56. }
  57. if (v == false || v == "false" || v == "" || v == "null") {
  58. return false;
  59. }
  60. return v;
  61. case Array.name:
  62. if (v === null || v == void 0 || !Array.isArray(v)) {
  63. return [];
  64. }
  65. return v;
  66. default:
  67. return v;
  68. }
  69. } catch (E) {
  70. return null;
  71. }
  72. }
  73. remove(k) {
  74. _GM_deleteValue(k);
  75. }
  76. }
  77. const Cache$1 = new Cache();
  78. const _export_sfc = (sfc, props) => {
  79. const target = sfc.__vccOpts || sfc;
  80. for (const [key, val] of props) {
  81. target[key] = val;
  82. }
  83. return target;
  84. };
  85. const _sfc_main$1 = {};
  86. const _hoisted_1$1 = /* @__PURE__ */ vue.createElementVNode("p", null, " 1. 本人目前测试过,没有封号,但是对于查询过题目会缓存在本地,因此尽量不要清空浏览器缓存 ", -1);
  87. const _hoisted_2$1 = /* @__PURE__ */ vue.createElementVNode("p", null, " 2. 脚本会监控题做题提交状态 ,当题目提交时候会缓存题目状态,如果题单中有这个题目,会直接从缓存中获取 ", -1);
  88. const _hoisted_3$1 = [
  89. _hoisted_1$1,
  90. _hoisted_2$1
  91. ];
  92. function _sfc_render(_ctx, _cache) {
  93. return vue.openBlock(), vue.createElementBlock("div", null, _hoisted_3$1);
  94. }
  95. const Q1 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
  96. const isLeetCodeCircleUrl = (url = window.location.href) => url && url.indexOf("https://leetcode.cn/circle") != -1;
  97. const isProblem = (url = window.location.href) => /^https?:\/\/leetcode.cn\/problems\/.*/i.test(url);
  98. const isContest = (url = window.location.href) => url.indexOf("https://leetcode.cn/contest/weekly-contest") != -1 || url.indexOf("https://leetcode.cn/contest/biweekly-contest") != -1;
  99. const width = 14;
  100. const height = 14;
  101. const problemFinsh = `
  102.  
  103. <svg width="${width}px" height="${height}px" status="ac" viewBox="0 0 1024 1024" version="1.1"
  104. xmlns="http://www.w3.org/2000/svg">
  105. <path d="M512 512m-448 0a448 448 0 1 0 896 0 448 448 0 1 0-896 0Z" fill="#4CAF50" />
  106. <path
  107. d="M738.133333 311.466667L448 601.6l-119.466667-119.466667-59.733333 59.733334 179.2 179.2 349.866667-349.866667z"
  108. fill="#CCFF90" />
  109. </svg>
  110.  
  111. `;
  112. const problemsTry = `
  113. <svg width="${width}px" height="${height}px" status="notac" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
  114. xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512"
  115. style="enable-background:new 0 0 512 512;" xml:space="preserve">
  116. <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
  117. S390.101,12.8,256,12.8z" />
  118. <g>
  119. <path style="fill:#573A32;" d="M256,115.2c-49.271,0-92.561,25.353-117.726,63.676l18.859,18.859
  120. 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
  121. C396.8,178.244,333.764,115.2,256,115.2z" />
  122. <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
  123. 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" />
  124. <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
  125. 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
  126. C334.822,348.194,298.266,371.2,256,371.2z" />
  127. </g>
  128. </svg>
  129.  
  130. `;
  131. const problemsNo = `
  132.  
  133. `;
  134. const inf = 4e3;
  135. const mi = 1e3;
  136. const __0x3f_problmes_solution__ = "__0x3f_problmes_solution__";
  137. const __0x3f_problmes_urls__ = "__0x3f_problmes_urls__";
  138. const __0x3f_problmes_update__ = "__0x3f_problmes_update__";
  139. const __is_none_0x3f_problmes_button__ = "__is_none_0x3f_problmes_button__";
  140. const __add_cur__ = "__add_cur__";
  141. const defaultObj = {
  142. min: mi,
  143. max: inf,
  144. visiableMember: true,
  145. onlyUrls: false,
  146. useDefaultSetting: true,
  147. hiddenAc: false
  148. };
  149. function isShow(text, min, max) {
  150. if (!text) {
  151. return true;
  152. }
  153. let res = text.match(/\d+/ig);
  154. if (!res) {
  155. return true;
  156. }
  157. if (Array.isArray(res) && res.length < 2) {
  158. return true;
  159. }
  160. let s = 0;
  161. for (let i = res.length - 1; i >= 0; i--) {
  162. s = res[i];
  163. if (s >= mi && s <= inf) {
  164. return s >= min && s <= max;
  165. }
  166. }
  167. return true;
  168. }
  169. let A = void 0;
  170. const queryProblem = () => Array.from(document.querySelectorAll(".css-1ayia3m-MarkdownContent li>a")).filter((item) => item && item instanceof HTMLAnchorElement && isProblem(item.href));
  171. function loadProblems() {
  172. A = queryProblem();
  173. }
  174. function handlerProblem(data) {
  175. var _a;
  176. try {
  177. loadProblems();
  178. let { min, max, visiableMember, useDefaultSetting, onlyUrls, hiddenAc } = data;
  179. if (isNaN(min) || isNaN(max)) {
  180. min = mi;
  181. max = inf;
  182. }
  183. if (min < mi) {
  184. min = mi;
  185. }
  186. if (max < min) {
  187. max = inf;
  188. }
  189. min = Number(min);
  190. max = Number(max);
  191. data.min = min;
  192. data.max = max;
  193. Cache$1.set(__0x3f_problmes_solution__, data);
  194. for (let i = 0; i < A.length; i++) {
  195. if (!(A[i] instanceof HTMLAnchorElement)) {
  196. continue;
  197. }
  198. let d = (_a = A[i]) == null ? void 0 : _a.parentNode;
  199. if (!d) {
  200. continue;
  201. }
  202. let none = false;
  203. let Nohidden = isShow(d.textContent, min, max);
  204. d.style.display = Nohidden ? "" : "none";
  205. if (!Nohidden) {
  206. continue;
  207. }
  208. if (hiddenAc) {
  209. const svg = d.querySelector("svg");
  210. if (svg && svg.getAttribute("status")) {
  211. d.style.display = svg.getAttribute("status") == STATUS["AC"] ? "none" : "";
  212. }
  213. } else {
  214. d.style.display = "";
  215. }
  216. let c = d.textContent && d.textContent.indexOf("会员") != -1;
  217. if (!c) {
  218. continue;
  219. }
  220. d.style.display = visiableMember ? "" : "none";
  221. }
  222. } catch (e) {
  223. console.log("error", e);
  224. }
  225. }
  226. const initUrls = () => Cache$1.get(__0x3f_problmes_update__, true, Boolean.name) ? Cache$1.get(__0x3f_problmes_urls__, true, Array.name) : defaultUrls;
  227. const initObj = () => Cache$1.get(__0x3f_problmes_solution__) ? Object.assign(defaultObj, Cache$1.get(__0x3f_problmes_solution__)) : defaultObj;
  228. const support_plugins = () => {
  229. const u = initObj();
  230. if (!u || !u.onlyUrls) return true;
  231. let url = window.location.href;
  232. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  233. try {
  234. url = url.split("view")[0];
  235. } catch (e) {
  236. url = window.location.href;
  237. }
  238. }
  239. const urls = initUrls();
  240. for (let info of urls) {
  241. if (!info || !(info == null ? void 0 : info.link)) {
  242. continue;
  243. }
  244. if (info.link.indexOf(url) != -1) {
  245. return true;
  246. }
  247. }
  248. return false;
  249. };
  250. const defaultUrls = [
  251. {
  252. title: "贪心算法(基本贪心策略/反悔/区间/字典序/数学/思维/构造)",
  253. link: "https://leetcode.cn/circle/discuss/g6KTKL/"
  254. },
  255. {
  256. title: "滑动窗口(定长/不定长/多指针)",
  257. link: "https://leetcode.cn/circle/discuss/0viNMK/"
  258. },
  259. {
  260. title: "二分算法(二分答案/最小化最大值/最大化最小值/第K小)",
  261. link: "https://leetcode.cn/circle/discuss/SqopEo/"
  262. },
  263. {
  264. title: "单调栈(矩形面积/贡献法/最小字典序)",
  265. link: "https://leetcode.cn/circle/discuss/9oZFK9/"
  266. },
  267. {
  268. title: "网格图(DFS/BFS/综合应用)",
  269. link: "https://leetcode.cn/circle/discuss/YiXPXW/"
  270. },
  271. {
  272. title: "位运算(基础/性质/拆位/试填/恒等式/贪心/脑筋急转弯)",
  273. link: "https://leetcode.cn/circle/discuss/dHn9Vk/"
  274. },
  275. {
  276. title: "图论算法(DFS/BFS/拓扑排序/最短路/最小生成树/二分图/基环树/欧拉路径)",
  277. link: "https://leetcode.cn/circle/discuss/01LUak/"
  278. },
  279. {
  280. title: "动态规划(入门/背包/状态机/划分/区间/状压/数位/树形/数据结构优化)",
  281. link: "https://leetcode.cn/circle/discuss/tXLS3i/"
  282. },
  283. {
  284. title: "常用数据结构(前缀和/差分/栈/队列/堆/字典树/并查集/树状数组/线段树)",
  285. link: "https://leetcode.cn/circle/discuss/mOr1u6/"
  286. },
  287. {
  288. title: "数学算法(数论/组合/概率期望/博弈/计算几何/随机算法)",
  289. link: "https://leetcode.cn/circle/discuss/IYT3ss/"
  290. }
  291. ];
  292. function getId(problemUrl) {
  293. if (isContest(problemUrl) || isProblem(problemUrl)) {
  294. try {
  295. return problemUrl.split("problems")[1].split("/")[1];
  296. } catch (e) {
  297. return "";
  298. }
  299. }
  300. return "";
  301. }
  302. const local_ok_problem_key = "__local_ok_problem_key__";
  303. const STATUS = {
  304. "AC": "ac",
  305. "NO": "null",
  306. "notac": "notac"
  307. };
  308. function postData(ID) {
  309. return {
  310. "query": "\n query userQuestionStatus($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n status\n }\n}\n ",
  311. "variables": {
  312. "titleSlug": ID
  313. },
  314. "operationName": "userQuestionStatus"
  315. };
  316. }
  317. function addProcess(reload = true) {
  318. var _a;
  319. loadProblems();
  320. let problems_doms = A;
  321. const cache = getLocalProblemStatus();
  322. for (let i = 0; i < problems_doms.length; i++) {
  323. let cur = problems_doms[i].parentElement;
  324. if (!(cur instanceof HTMLElement)) {
  325. continue;
  326. }
  327. const ID = getId((_a = problems_doms[i]) == null ? void 0 : _a.href);
  328. if (!ID) {
  329. continue;
  330. }
  331. if (cache[ID]) {
  332. let status = cache[ID];
  333. const svg = cur.querySelector("svg");
  334. if (svg) {
  335. if (svg.getAttribute("status") == status) {
  336. continue;
  337. }
  338. svg.remove();
  339. }
  340. cur.innerHTML = cur.innerHTML + (status == STATUS["AC"] ? problemFinsh : status == STATUS["notac"] ? problemsTry : problemsNo);
  341. } else {
  342. fetch("https://leetcode.cn/graphql/", {
  343. method: "POST",
  344. credentials: "include",
  345. headers: {
  346. "Content-Type": "application/json"
  347. },
  348. body: JSON.stringify(postData(ID))
  349. }).then((res) => res.json()).then((response) => {
  350. var _a2, _b;
  351. const status = (_b = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.question) == null ? void 0 : _b.status;
  352. if (status == STATUS["AC"]) {
  353. cur.innerHTML = cur.innerHTML + problemFinsh;
  354. } else if (status == STATUS["notac"]) {
  355. cur.innerHTML = cur.innerHTML + problemsTry;
  356. } else {
  357. {
  358. cur.innerHTML = cur.innerHTML + problemsNo;
  359. }
  360. }
  361. cache[ID] = status == null ? "null" : status;
  362. if (cur.parentElement) {
  363. cur.parentElement.status = cache[ID];
  364. }
  365. }).catch((ignore) => {
  366. });
  367. }
  368. }
  369. if (reload) {
  370. let cnt = 10;
  371. let timeId = setInterval(() => {
  372. Cache$1.set(local_ok_problem_key, cache);
  373. cnt--;
  374. if (cnt == 0) {
  375. window.clearInterval(timeId);
  376. }
  377. }, 3e3);
  378. }
  379. }
  380. const submitProblems = (url = window.location.href) => {
  381. const ID = getId(url);
  382. if (!ID) {
  383. return;
  384. }
  385. setTimeout(() => {
  386. const cache = getLocalProblemStatus();
  387. console.log("ID:", ID, "query status: ", cache[ID]);
  388. if (cache[ID] == void 0 || cache[ID] != STATUS["AC"]) {
  389. fetch("https://leetcode.cn/graphql/", {
  390. method: "POST",
  391. credentials: "include",
  392. headers: {
  393. "Content-Type": "application/json"
  394. },
  395. body: JSON.stringify(postData(ID))
  396. }).then((res) => res.json()).then((response) => {
  397. var _a, _b;
  398. const status = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.question) == null ? void 0 : _b.status;
  399. if (cache[ID] != status) {
  400. cache[ID] = status == null ? "null" : status;
  401. console.log("save local status :", cache[ID]);
  402. Cache$1.set(local_ok_problem_key, cache);
  403. }
  404. }).catch((ignore) => {
  405. });
  406. }
  407. }, 500);
  408. };
  409. function getProcess() {
  410. loadProblems();
  411. const cache = getLocalProblemStatus();
  412. let cnt = 0;
  413. for (let i = 0; i < A.length; i++) {
  414. let ID = getId(A[i].href);
  415. if (ID && cache[ID] == STATUS["AC"]) {
  416. cnt++;
  417. }
  418. }
  419. return [cnt, A.length];
  420. }
  421. function getLocalProblemStatus() {
  422. return Cache$1.get(local_ok_problem_key, true, Object.name);
  423. }
  424. const _hoisted_1 = { class: "processs-flex" };
  425. const _hoisted_2 = { style: { "text-align": "center", "color": "#121212" } };
  426. const _hoisted_3 = { class: "dialog-footer" };
  427. const formLabelWidth = "44px";
  428. const _sfc_main = {
  429. __name: "App",
  430. setup(__props) {
  431. let totProblem = vue.ref(0);
  432. let finishProblem = vue.ref(0);
  433. const drawer = vue.ref(false);
  434. const viewSetting = () => {
  435. drawer.value = !drawer.value;
  436. let [cur, tot] = getProcess();
  437. finishProblem.value = cur;
  438. totProblem.value = tot;
  439. };
  440. const finishProcess = vue.computed(() => {
  441. try {
  442. const s = String(finishProblem.value / totProblem.value);
  443. let x1 = s.split(".")[1].padEnd(3).substring(0, 3);
  444. return Math.min(100, Number(x1) / 10);
  445. } catch (e) {
  446. return (finishProblem.value / totProblem.value).toFixed(3) * 100;
  447. }
  448. });
  449. const processColors = [
  450. { color: "#f56c6c", percentage: 20 },
  451. { color: "#1989fa", percentage: 40 },
  452. { color: "#e6a23c", percentage: 60 },
  453. { color: "#6f7ad3", percentage: 80 },
  454. { color: "#5cb87a", percentage: 100 }
  455. ];
  456. const fromData = vue.reactive(initObj());
  457. vue.watch(fromData, () => {
  458. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  459. });
  460. let tableData = vue.reactive(initUrls());
  461. const keywords = vue.ref("");
  462. const dialogTableVisible = vue.ref(false);
  463. const urlsData = vue.computed(() => tableData.filter((v) => v && v.title && v.title.indexOf(keywords.value) != -1));
  464. const isDisabbled = vue.computed(() => !!tableData.find((v) => (v == null ? void 0 : v.link) && (v == null ? void 0 : v.link.indexOf(window.location.href)) != -1));
  465. const dialogFormVisible = vue.ref(false);
  466. const info = vue.reactive({
  467. title: "",
  468. link: "",
  469. status: "add"
  470. });
  471. const addlocal = () => {
  472. if (!isDisabbled) {
  473. return;
  474. }
  475. tableData.unshift({ title: document.title, link: window.location.href });
  476. };
  477. const updateIndex = vue.ref(-1);
  478. const showProblems = () => {
  479. dialogTableVisible.value = true;
  480. let o = Cache$1.get(__add_cur__) == "true" || Cache$1.get(__add_cur__) == true;
  481. if (o) {
  482. addlocal();
  483. }
  484. };
  485. const handlerProblems = (status, updateInfo = { title: "", link: "" }, index = -1) => {
  486. dialogFormVisible.value = true;
  487. info.status = status;
  488. updateIndex.value = index;
  489. Object.assign(info, updateInfo);
  490. };
  491. const handlerMessage = (u, title, link) => {
  492. const a = u ? "添加" : "修改";
  493. const error = !title || !/https?:\/\/.*/.test(link);
  494. if (error) {
  495. ElementPlus.ElMessage.error(`${a} 失败 请保证标题或者链接有效 `);
  496. } else {
  497. ElementPlus.ElMessage.success(`${a} 成功 `);
  498. }
  499. return !error;
  500. };
  501. const addOrUpdate = () => {
  502. if (!handlerMessage(info.status == "add", info.title, info.link)) {
  503. return;
  504. }
  505. if (info.status == "add") {
  506. tableData.unshift({ title: info.title, link: info.link });
  507. } else {
  508. let index = updateIndex.value;
  509. if (index != -1 && index < tableData.length) {
  510. tableData[index].link = info.link;
  511. tableData[index].title = info.title;
  512. }
  513. }
  514. dialogFormVisible.value = false;
  515. };
  516. const deleteProblems = (index) => {
  517. tableData.splice(index, 1);
  518. Cache$1.set(__0x3f_problmes_urls__, vue.toRaw(tableData));
  519. };
  520. const handlerDefault = () => {
  521. ElementPlus.ElMessageBox.confirm(
  522. "确认使用默认题单,将会重置题单?",
  523. "警告",
  524. {
  525. confirmButtonText: "确认",
  526. cancelButtonText: "取消",
  527. type: "warning"
  528. }
  529. ).then(() => {
  530. for (let i = 0; i < tableData.length; i++) {
  531. delete tableData[i];
  532. }
  533. for (let item of defaultUrls) {
  534. tableData.unshift(item);
  535. }
  536. ElementPlus.ElMessage({
  537. type: "success",
  538. message: "重置成功"
  539. });
  540. }).catch(() => {
  541. ElementPlus.ElMessage({
  542. type: "info",
  543. message: "取消重置"
  544. });
  545. });
  546. };
  547. window.addEventListener("beforeunload", () => {
  548. Cache$1.set(__0x3f_problmes_urls__, vue.toRaw(tableData).filter((u) => u != null && u != void 0));
  549. Cache$1.set(__0x3f_problmes_update__, true);
  550. Cache$1.set(__add_cur__, false);
  551. });
  552. vue.onMounted(() => {
  553. if (support_plugins()) {
  554. let times = 30;
  555. let loadTimeId = setInterval(() => {
  556. let a = queryProblem();
  557. times--;
  558. if (Array.isArray(a) && a.length > 0) {
  559. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  560. addProcess();
  561. window.clearInterval(loadTimeId);
  562. }
  563. if (times == 0) {
  564. window.clearInterval(loadTimeId);
  565. }
  566. }, 500);
  567. setInterval(() => {
  568. addProcess(false);
  569. }, 1e3 * 60 * 0.5);
  570. }
  571. });
  572. const q1 = vue.ref(false);
  573. return (_ctx, _cache) => {
  574. const _component_el_button = vue.resolveComponent("el-button");
  575. const _component_el_progress = vue.resolveComponent("el-progress");
  576. const _component_el_divider = vue.resolveComponent("el-divider");
  577. const _component_el_input = vue.resolveComponent("el-input");
  578. const _component_el_col = vue.resolveComponent("el-col");
  579. const _component_el_form_item = vue.resolveComponent("el-form-item");
  580. const _component_el_switch = vue.resolveComponent("el-switch");
  581. const _component_el_tooltip = vue.resolveComponent("el-tooltip");
  582. const _component_el_form = vue.resolveComponent("el-form");
  583. const _component_el_dialog = vue.resolveComponent("el-dialog");
  584. const _component_el_row = vue.resolveComponent("el-row");
  585. const _component_el_link = vue.resolveComponent("el-link");
  586. const _component_el_table_column = vue.resolveComponent("el-table-column");
  587. const _component_el_table = vue.resolveComponent("el-table");
  588. const _component_el_drawer = vue.resolveComponent("el-drawer");
  589. return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
  590. vue.createElementVNode("div", null, [
  591. vue.createVNode(_component_el_button, {
  592. type: "primary",
  593. style: {},
  594. onClick: viewSetting,
  595. class: "m-setting-button m-button",
  596. circle: "",
  597. size: "large"
  598. }, {
  599. default: vue.withCtx(() => [
  600. vue.createTextVNode(" 0X3F ")
  601. ]),
  602. _: 1
  603. })
  604. ]),
  605. vue.createVNode(_component_el_drawer, {
  606. modelValue: drawer.value,
  607. "onUpdate:modelValue": _cache[17] || (_cache[17] = ($event) => drawer.value = $event),
  608. "with-header": false,
  609. size: "30%"
  610. }, {
  611. default: vue.withCtx(() => [
  612. vue.createElementVNode("div", _hoisted_1, [
  613. vue.createVNode(_component_el_progress, {
  614. type: "circle",
  615. percentage: finishProcess.value,
  616. color: processColors
  617. }, {
  618. default: vue.withCtx(({ percentage }) => [
  619. vue.createElementVNode("p", null, vue.toDisplayString(percentage) + "%", 1)
  620. ]),
  621. _: 1
  622. }, 8, ["percentage"])
  623. ]),
  624. vue.createElementVNode("p", _hoisted_2, vue.toDisplayString(vue.unref(finishProblem)) + " / " + vue.toDisplayString(vue.unref(totProblem)), 1),
  625. vue.createCommentVNode("", true),
  626. vue.createVNode(_component_el_divider),
  627. vue.createVNode(_component_el_form, {
  628. "label-position": "left",
  629. "label-width": "auto",
  630. model: fromData,
  631. style: { "max-width": "600px" }
  632. }, {
  633. default: vue.withCtx(() => [
  634. vue.createVNode(_component_el_form_item, { label: "分数区间" }, {
  635. default: vue.withCtx(() => [
  636. vue.createVNode(_component_el_col, { span: 10 }, {
  637. default: vue.withCtx(() => [
  638. vue.createVNode(_component_el_input, {
  639. modelValue: fromData.min,
  640. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => fromData.min = $event),
  641. "aria-placeholder": "",
  642. placeholder: " min "
  643. }, null, 8, ["modelValue"])
  644. ]),
  645. _: 1
  646. }),
  647. vue.createVNode(_component_el_col, {
  648. class: "text-center",
  649. span: 1,
  650. style: { "margin": "0 0.5rem" }
  651. }, {
  652. default: vue.withCtx(() => [
  653. vue.createTextVNode("-")
  654. ]),
  655. _: 1
  656. }),
  657. vue.createVNode(_component_el_col, { span: 10 }, {
  658. default: vue.withCtx(() => [
  659. vue.createVNode(_component_el_input, {
  660. modelValue: fromData.max,
  661. "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => fromData.max = $event),
  662. "aria-placeholder": "",
  663. placeholder: " max"
  664. }, null, 8, ["modelValue"])
  665. ]),
  666. _: 1
  667. })
  668. ]),
  669. _: 1
  670. }),
  671. vue.createVNode(_component_el_form_item, { label: "显示会员题" }, {
  672. default: vue.withCtx(() => [
  673. vue.createVNode(_component_el_switch, {
  674. modelValue: fromData.visiableMember,
  675. "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => fromData.visiableMember = $event)
  676. }, null, 8, ["modelValue"])
  677. ]),
  678. _: 1
  679. }),
  680. vue.createVNode(_component_el_form_item, { label: "隐藏AC题目" }, {
  681. default: vue.withCtx(() => [
  682. vue.createVNode(_component_el_switch, {
  683. modelValue: fromData.hiddenAc,
  684. "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => fromData.hiddenAc = $event)
  685. }, null, 8, ["modelValue"])
  686. ]),
  687. _: 1
  688. }),
  689. vue.createVNode(_component_el_form_item, { label: "收藏题单中生效" }, {
  690. default: vue.withCtx(() => [
  691. vue.createVNode(_component_el_tooltip, {
  692. content: "插件只在收藏题单中生效,刷新生效 ",
  693. placement: "bottom-end"
  694. }, {
  695. default: vue.withCtx(() => [
  696. vue.createVNode(_component_el_switch, {
  697. modelValue: fromData.onlyUrls,
  698. "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => fromData.onlyUrls = $event)
  699. }, null, 8, ["modelValue"])
  700. ]),
  701. _: 1
  702. })
  703. ]),
  704. _: 1
  705. }),
  706. vue.createVNode(_component_el_form_item, { label: "使用题单" }, {
  707. default: vue.withCtx(() => [
  708. vue.createVNode(_component_el_switch, {
  709. modelValue: fromData.useDefaultSetting,
  710. "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => fromData.useDefaultSetting = $event)
  711. }, null, 8, ["modelValue"])
  712. ]),
  713. _: 1
  714. })
  715. ]),
  716. _: 1
  717. }, 8, ["model"]),
  718. fromData.useDefaultSetting ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
  719. vue.createVNode(_component_el_divider),
  720. vue.createVNode(_component_el_button, {
  721. plain: "",
  722. onClick: showProblems
  723. }, {
  724. default: vue.withCtx(() => [
  725. vue.createTextVNode(" 查看收藏的题单 ")
  726. ]),
  727. _: 1
  728. }),
  729. vue.createVNode(_component_el_divider)
  730. ], 64)) : vue.createCommentVNode("", true),
  731. vue.createVNode(_component_el_button, {
  732. plain: "",
  733. onClick: _cache[8] || (_cache[8] = ($event) => q1.value = !q1.value)
  734. }, {
  735. default: vue.withCtx(() => [
  736. vue.createTextVNode(" 问题1 ")
  737. ]),
  738. _: 1
  739. }),
  740. vue.createVNode(_component_el_divider),
  741. vue.createVNode(_component_el_dialog, {
  742. modelValue: q1.value,
  743. "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => q1.value = $event),
  744. title: "关于查询状态会不会被封号 ?"
  745. }, {
  746. default: vue.withCtx(() => [
  747. vue.createVNode(Q1)
  748. ]),
  749. _: 1
  750. }, 8, ["modelValue"]),
  751. vue.createVNode(_component_el_dialog, {
  752. modelValue: dialogTableVisible.value,
  753. "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => dialogTableVisible.value = $event),
  754. title: "题单"
  755. }, {
  756. default: vue.withCtx(() => [
  757. vue.createVNode(_component_el_row, { gutter: 10 }, {
  758. default: vue.withCtx(() => [
  759. vue.createVNode(_component_el_col, { span: 8 }, {
  760. default: vue.withCtx(() => [
  761. vue.createVNode(_component_el_input, {
  762. modelValue: keywords.value,
  763. "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => keywords.value = $event),
  764. placeholder: "请输入关键词过滤",
  765. clearable: ""
  766. }, null, 8, ["modelValue"])
  767. ]),
  768. _: 1
  769. }),
  770. vue.createVNode(_component_el_col, { span: 16 }, {
  771. default: vue.withCtx(() => [
  772. vue.createVNode(_component_el_button, {
  773. plain: "",
  774. onClick: addlocal,
  775. disabled: isDisabbled.value
  776. }, {
  777. default: vue.withCtx(() => [
  778. vue.createTextVNode(" 添加本页 ")
  779. ]),
  780. _: 1
  781. }, 8, ["disabled"]),
  782. vue.createVNode(_component_el_button, {
  783. plain: "",
  784. onClick: _cache[11] || (_cache[11] = ($event) => handlerProblems("add"))
  785. }, {
  786. default: vue.withCtx(() => [
  787. vue.createTextVNode(" 自定义 ")
  788. ]),
  789. _: 1
  790. }),
  791. vue.createVNode(_component_el_button, {
  792. plain: "",
  793. onClick: handlerDefault
  794. }, {
  795. default: vue.withCtx(() => [
  796. vue.createTextVNode(" 默认 ")
  797. ]),
  798. _: 1
  799. })
  800. ]),
  801. _: 1
  802. })
  803. ]),
  804. _: 1
  805. }),
  806. vue.createVNode(_component_el_table, {
  807. data: urlsData.value,
  808. height: "300",
  809. style: { "width": "100%", "margin-top": "10px" }
  810. }, {
  811. default: vue.withCtx(() => [
  812. vue.createVNode(_component_el_table_column, {
  813. label: "标题",
  814. width: "auto",
  815. align: "center"
  816. }, {
  817. default: vue.withCtx((scope) => [
  818. vue.createVNode(_component_el_link, {
  819. href: scope.row.link,
  820. target: "_blank",
  821. type: "default"
  822. }, {
  823. default: vue.withCtx(() => [
  824. vue.createTextVNode(vue.toDisplayString(scope.row.title), 1)
  825. ]),
  826. _: 2
  827. }, 1032, ["href"])
  828. ]),
  829. _: 1
  830. }),
  831. vue.createVNode(_component_el_table_column, {
  832. label: "操作",
  833. width: "auto",
  834. align: "center"
  835. }, {
  836. default: vue.withCtx((scope) => [
  837. vue.createVNode(_component_el_button, {
  838. type: "primary",
  839. size: "small",
  840. onClick: ($event) => handlerProblems("update", scope.row, scope.$index)
  841. }, {
  842. default: vue.withCtx(() => [
  843. vue.createTextVNode("编辑")
  844. ]),
  845. _: 2
  846. }, 1032, ["onClick"]),
  847. vue.createVNode(_component_el_button, {
  848. type: "danger",
  849. size: "small",
  850. onClick: ($event) => deleteProblems(scope.$index)
  851. }, {
  852. default: vue.withCtx(() => [
  853. vue.createTextVNode("删除")
  854. ]),
  855. _: 2
  856. }, 1032, ["onClick"])
  857. ]),
  858. _: 1
  859. })
  860. ]),
  861. _: 1
  862. }, 8, ["data"])
  863. ]),
  864. _: 1
  865. }, 8, ["modelValue"]),
  866. vue.createVNode(_component_el_dialog, {
  867. modelValue: dialogFormVisible.value,
  868. "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => dialogFormVisible.value = $event),
  869. title: `${info.status == "add" ? "添加" : "编辑"}`,
  870. width: "400"
  871. }, {
  872. footer: vue.withCtx(() => [
  873. vue.createElementVNode("div", _hoisted_3, [
  874. vue.createVNode(_component_el_button, {
  875. onClick: _cache[15] || (_cache[15] = ($event) => dialogFormVisible.value = false)
  876. }, {
  877. default: vue.withCtx(() => [
  878. vue.createTextVNode("取消")
  879. ]),
  880. _: 1
  881. }),
  882. vue.createVNode(_component_el_button, {
  883. type: "primary",
  884. onClick: addOrUpdate
  885. }, {
  886. default: vue.withCtx(() => [
  887. vue.createTextVNode(" 确认 ")
  888. ]),
  889. _: 1
  890. })
  891. ])
  892. ]),
  893. default: vue.withCtx(() => [
  894. vue.createVNode(_component_el_form, null, {
  895. default: vue.withCtx(() => [
  896. vue.createVNode(_component_el_form_item, {
  897. label: "标题",
  898. "label-width": formLabelWidth
  899. }, {
  900. default: vue.withCtx(() => [
  901. vue.createVNode(_component_el_input, {
  902. modelValue: info.title,
  903. "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => info.title = $event),
  904. autocomplete: "off"
  905. }, null, 8, ["modelValue"])
  906. ]),
  907. _: 1
  908. }),
  909. vue.createVNode(_component_el_form_item, {
  910. label: "链接",
  911. "label-width": formLabelWidth
  912. }, {
  913. default: vue.withCtx(() => [
  914. vue.createVNode(_component_el_input, {
  915. modelValue: info.link,
  916. "onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => info.link = $event),
  917. autocomplete: "off"
  918. }, null, 8, ["modelValue"])
  919. ]),
  920. _: 1
  921. })
  922. ]),
  923. _: 1
  924. })
  925. ]),
  926. _: 1
  927. }, 8, ["modelValue", "title"])
  928. ]),
  929. _: 1
  930. }, 8, ["modelValue"])
  931. ], 64);
  932. };
  933. }
  934. };
  935. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-feb4b33e"]]);
  936. const cssLoader = (e) => {
  937. const t = GM_getResourceText(e);
  938. return GM_addStyle(t), t;
  939. };
  940. cssLoader("elementPlusCss");
  941. const stopRankingKey = "__is_stop_rating_ranking__";
  942. let conetstTimeId = null;
  943. function run$1() {
  944. const container = document.querySelector(".contest-question-info .list-group");
  945. if (!container) return;
  946. const ls = Array.from(container.querySelectorAll(".list-group-item .pull-right"));
  947. for (let i = 0; i < 4; i++) {
  948. if (i >= ls.length) {
  949. break;
  950. }
  951. if (ls[i] instanceof HTMLElement) {
  952. ls[i].textContent = "0";
  953. }
  954. }
  955. window.clearInterval(conetstTimeId);
  956. }
  957. function startStopRanking() {
  958. if (!isContest(window.location.href)) {
  959. return;
  960. }
  961. const isNext = !!document.querySelector("#__next");
  962. if (isNext) {
  963. return;
  964. }
  965. const use = Cache$1.get(stopRankingKey);
  966. _GM_registerMenuCommand(`${use ? "使用" : "关闭"} 排行榜`, () => {
  967. Cache$1.set(stopRankingKey, !use);
  968. window.location.reload();
  969. }, { title: "对于不想看到排行榜的可以使用此功能 默认开启" });
  970. if (!use) {
  971. return;
  972. }
  973. conetstTimeId = setInterval(() => {
  974. run$1();
  975. }, 10);
  976. }
  977. const local_url = window.location.href;
  978. let loadID = 0;
  979. let submitCnt = 0;
  980. function watchDom(dom) {
  981. if (!(dom instanceof HTMLElement)) {
  982. return;
  983. }
  984. let m = new MutationObserver(() => {
  985. if (submitCnt % 2 == 1) {
  986. submitProblems(local_url);
  987. }
  988. submitCnt++;
  989. });
  990. m.observe(dom, {
  991. childList: true,
  992. attributes: true
  993. });
  994. }
  995. function run() {
  996. loadID++;
  997. if (isProblem(local_url) || isContest(local_url)) {
  998. if (isProblem(local_url) && loadID == 1) {
  999. submitProblems(local_url);
  1000. }
  1001. setTimeout(() => {
  1002. let submitbutton = null;
  1003. const isNext = !!document.querySelector("#__next");
  1004. if (isProblem(local_url) || isNext) {
  1005. submitbutton = document.querySelector("div [data-e2e-locator=console-submit-button]");
  1006. } else {
  1007. let buttons = Array.from(document.querySelectorAll(".question-detail-bottom .pull-right button"));
  1008. for (let i = buttons.length - 1; i >= 0; i--) {
  1009. if (buttons[i].textContent.indexOf("提交解答") != -1) {
  1010. submitbutton = buttons[i];
  1011. break;
  1012. }
  1013. }
  1014. }
  1015. if (submitbutton) {
  1016. watchDom(submitbutton);
  1017. } else if (loadID < 10) {
  1018. run();
  1019. }
  1020. }, 3e3);
  1021. } else if (isLeetCodeCircleUrl(local_url)) {
  1022. let Container = null;
  1023. let ok = Cache$1.get(__is_none_0x3f_problmes_button__, true, Boolean.name);
  1024. const start = () => {
  1025. Container = document.createElement("div");
  1026. const body = document.querySelector("body");
  1027. body.append(Container);
  1028. Container.style.display = ok && support_plugins() ? "block" : "none";
  1029. return Container;
  1030. };
  1031. let dom = start();
  1032. const VueApp = vue.createApp(App);
  1033. _GM_registerMenuCommand(`${ok ? "隐藏按钮" : "显示按钮"}`, () => {
  1034. ok = !ok;
  1035. Container.style.display = ok ? "block" : "none";
  1036. Cache$1.set(__is_none_0x3f_problmes_button__, ok);
  1037. }, { title: "可以手动关闭或者显示按钮 默认显示 刷新生效" });
  1038. _GM_registerMenuCommand(`${initObj().onlyUrls ? "仅在收藏题单页面生效" : "所有题单生效"}`, () => {
  1039. const u = initObj();
  1040. u.onlyUrls = !u.onlyUrls;
  1041. Container.style.display = support_plugins() ? "block" : "none";
  1042. Cache$1.set(__0x3f_problmes_solution__, u);
  1043. });
  1044. _GM_registerMenuCommand(`添加本页`, () => {
  1045. const urls = initUrls();
  1046. let ok2 = false;
  1047. let url = window.location.href;
  1048. for (let info of urls) {
  1049. if (!info || !(info == null ? void 0 : info.link)) {
  1050. continue;
  1051. }
  1052. if (info.link.indexOf(url) != -1) {
  1053. ok2 = true;
  1054. break;
  1055. }
  1056. }
  1057. if (ok2) {
  1058. ElementPlus.ElMessage({
  1059. message: "收藏失败,链接已经存在!",
  1060. type: "error"
  1061. });
  1062. } else {
  1063. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  1064. try {
  1065. url = url.split("view")[0];
  1066. } catch (e) {
  1067. url = window.location.href;
  1068. }
  1069. }
  1070. urls.unshift({
  1071. title: document.title,
  1072. link: url
  1073. });
  1074. Container.style.display = "block";
  1075. Cache$1.set(__0x3f_problmes_urls__, urls);
  1076. Cache$1.set(__0x3f_problmes_update__, true);
  1077. Cache$1.set(__add_cur__, true);
  1078. ElementPlus.ElMessage({
  1079. message: "收藏成功!刷新生效",
  1080. type: "success"
  1081. });
  1082. }
  1083. });
  1084. VueApp.use(ElementPlus).mount(dom);
  1085. }
  1086. }
  1087. run();
  1088. startStopRanking();
  1089.  
  1090. })(Vue, ElementPlus);