0x3f-problem-solution

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

As of 26/07/2024. See the latest version.

  1. // ==UserScript==
  2. // @name 0x3f-problem-solution
  3. // @namespace https://greatest.deepsurf.us/zh-CN/scripts/501134-0x3f-problem-solution
  4. // @version 0.0.4
  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://greatest.deepsurf.us/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-52bea08d]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-52bea08d]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-52bea08d]{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() {
  318. var _a;
  319. loadProblems();
  320. let problems_doms = A;
  321. const cache = getLocalProblemStatus();
  322. let uid = 0;
  323. for (let i = 0; i < problems_doms.length; i++) {
  324. let cur = problems_doms[i].parentElement;
  325. if (!(cur instanceof HTMLElement) || (cur == null ? void 0 : cur.mark)) {
  326. continue;
  327. }
  328. const ID = getId((_a = problems_doms[i]) == null ? void 0 : _a.href);
  329. if (!ID) {
  330. continue;
  331. }
  332. if (cache[ID]) {
  333. let status = cache[ID];
  334. uid++;
  335. cur.innerHTML = cur.innerHTML + (status == STATUS["AC"] ? problemFinsh : status == STATUS["notac"] ? problemsTry : problemsNo);
  336. } else {
  337. fetch("https://leetcode.cn/graphql/", {
  338. method: "POST",
  339. credentials: "include",
  340. headers: {
  341. "Content-Type": "application/json"
  342. },
  343. body: JSON.stringify(postData(ID))
  344. }).then((res) => res.json()).then((response) => {
  345. var _a2, _b;
  346. const status = (_b = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.question) == null ? void 0 : _b.status;
  347. if (status == STATUS["AC"]) {
  348. cur.innerHTML = cur.innerHTML + problemFinsh;
  349. } else if (status == STATUS["notac"]) {
  350. cur.innerHTML = cur.innerHTML + problemsTry;
  351. } else {
  352. {
  353. cur.innerHTML = cur.innerHTML + problemsNo;
  354. }
  355. }
  356. cache[ID] = status == null ? "null" : status;
  357. if (cur.parentElement) {
  358. cur.parentElement.status = cache[ID];
  359. }
  360. }).catch((ignore) => {
  361. });
  362. }
  363. cur.mark = true;
  364. }
  365. console.log("cache num :", uid, "tot:", A.length);
  366. let cnt = 10;
  367. let timeId = setInterval(() => {
  368. Cache$1.set(local_ok_problem_key, cache);
  369. cnt--;
  370. if (cnt == 0) {
  371. window.clearInterval(timeId);
  372. }
  373. }, 3e3);
  374. }
  375. const submitProblems = (url = window.location.href) => {
  376. const ID = getId(url);
  377. if (!ID) {
  378. return;
  379. }
  380. setTimeout(() => {
  381. const cache = getLocalProblemStatus();
  382. console.log("ID:", ID, "query status: ", cache[ID]);
  383. if (cache[ID] == void 0 || cache[ID] != STATUS["AC"]) {
  384. fetch("https://leetcode.cn/graphql/", {
  385. method: "POST",
  386. credentials: "include",
  387. headers: {
  388. "Content-Type": "application/json"
  389. },
  390. body: JSON.stringify(postData(ID))
  391. }).then((res) => res.json()).then((response) => {
  392. var _a, _b;
  393. const status = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.question) == null ? void 0 : _b.status;
  394. if (cache[ID] != status) {
  395. cache[ID] = status == null ? "null" : status;
  396. console.log("save local status :", cache[ID]);
  397. Cache$1.set(local_ok_problem_key, cache);
  398. }
  399. }).catch((ignore) => {
  400. });
  401. }
  402. }, 3e3);
  403. };
  404. function getProcess() {
  405. loadProblems();
  406. const cache = getLocalProblemStatus();
  407. let cnt = 0;
  408. for (let i = 0; i < A.length; i++) {
  409. let ID = getId(A[i].href);
  410. if (ID && cache[ID] == STATUS["AC"]) {
  411. cnt++;
  412. }
  413. }
  414. return [cnt, A.length];
  415. }
  416. function getLocalProblemStatus() {
  417. return Cache$1.get(local_ok_problem_key, true, Object.name);
  418. }
  419. const _hoisted_1 = { class: "processs-flex" };
  420. const _hoisted_2 = { style: { "text-align": "center", "color": "#121212" } };
  421. const _hoisted_3 = { class: "dialog-footer" };
  422. const formLabelWidth = "44px";
  423. const _sfc_main = {
  424. __name: "App",
  425. setup(__props) {
  426. let totProblem = vue.ref(0);
  427. let finishProblem = vue.ref(0);
  428. const drawer = vue.ref(false);
  429. const viewSetting = () => {
  430. drawer.value = !drawer.value;
  431. let [cur, tot] = getProcess();
  432. finishProblem.value = cur;
  433. totProblem.value = tot;
  434. };
  435. const finishProcess = vue.computed(() => {
  436. try {
  437. const s = String(finishProblem.value / totProblem.value);
  438. let x1 = s.split(".")[1].padEnd(3).substring(0, 3);
  439. return Math.min(100, Number(x1) / 10);
  440. } catch (e) {
  441. return (finishProblem.value / totProblem.value).toFixed(3) * 100;
  442. }
  443. });
  444. const processColors = [
  445. { color: "#f56c6c", percentage: 20 },
  446. { color: "#1989fa", percentage: 40 },
  447. { color: "#e6a23c", percentage: 60 },
  448. { color: "#6f7ad3", percentage: 80 },
  449. { color: "#5cb87a", percentage: 100 }
  450. ];
  451. const fromData = vue.reactive(initObj());
  452. vue.watch(fromData, () => {
  453. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  454. });
  455. let tableData = vue.reactive(initUrls());
  456. const keywords = vue.ref("");
  457. const dialogTableVisible = vue.ref(false);
  458. const urlsData = vue.computed(() => tableData.filter((v) => v && v.title && v.title.indexOf(keywords.value) != -1));
  459. const isDisabbled = vue.computed(() => !!tableData.find((v) => (v == null ? void 0 : v.link) && (v == null ? void 0 : v.link.indexOf(window.location.href)) != -1));
  460. const dialogFormVisible = vue.ref(false);
  461. const info = vue.reactive({
  462. title: "",
  463. link: "",
  464. status: "add"
  465. });
  466. const addlocal = () => {
  467. if (!isDisabbled) {
  468. return;
  469. }
  470. tableData.unshift({ title: document.title, link: window.location.href });
  471. };
  472. const updateIndex = vue.ref(-1);
  473. const showProblems = () => {
  474. dialogTableVisible.value = true;
  475. let o = Cache$1.get(__add_cur__) == "true" || Cache$1.get(__add_cur__) == true;
  476. if (o) {
  477. addlocal();
  478. }
  479. };
  480. const handlerProblems = (status, updateInfo = { title: "", link: "" }, index = -1) => {
  481. dialogFormVisible.value = true;
  482. info.status = status;
  483. updateIndex.value = index;
  484. Object.assign(info, updateInfo);
  485. };
  486. const handlerMessage = (u, title, link) => {
  487. const a = u ? "添加" : "修改";
  488. const error = !title || !/https?:\/\/.*/.test(link);
  489. if (error) {
  490. ElementPlus.ElMessage.error(`${a} 失败 请保证标题或者链接有效 `);
  491. } else {
  492. ElementPlus.ElMessage.success(`${a} 成功 `);
  493. }
  494. return !error;
  495. };
  496. const addOrUpdate = () => {
  497. if (!handlerMessage(info.status == "add", info.title, info.link)) {
  498. return;
  499. }
  500. if (info.status == "add") {
  501. tableData.unshift({ title: info.title, link: info.link });
  502. } else {
  503. let index = updateIndex.value;
  504. if (index != -1 && index < tableData.length) {
  505. tableData[index].link = info.link;
  506. tableData[index].title = info.title;
  507. }
  508. }
  509. dialogFormVisible.value = false;
  510. };
  511. const deleteProblems = (index) => {
  512. tableData.splice(index, 1);
  513. Cache$1.set(__0x3f_problmes_urls__, vue.toRaw(tableData));
  514. };
  515. const handlerDefault = () => {
  516. ElementPlus.ElMessageBox.confirm(
  517. "确认使用默认题单,将会重置题单?",
  518. "警告",
  519. {
  520. confirmButtonText: "确认",
  521. cancelButtonText: "取消",
  522. type: "warning"
  523. }
  524. ).then(() => {
  525. for (let i = 0; i < tableData.length; i++) {
  526. delete tableData[i];
  527. }
  528. for (let item of defaultUrls) {
  529. tableData.unshift(item);
  530. }
  531. ElementPlus.ElMessage({
  532. type: "success",
  533. message: "重置成功"
  534. });
  535. }).catch(() => {
  536. ElementPlus.ElMessage({
  537. type: "info",
  538. message: "取消重置"
  539. });
  540. });
  541. };
  542. window.addEventListener("beforeunload", () => {
  543. Cache$1.set(__0x3f_problmes_urls__, vue.toRaw(tableData).filter((u) => u != null && u != void 0));
  544. Cache$1.set(__0x3f_problmes_update__, true);
  545. Cache$1.set(__add_cur__, false);
  546. });
  547. vue.onMounted(() => {
  548. if (support_plugins()) {
  549. let times = 30;
  550. let loadTimeId = setInterval(() => {
  551. let a = queryProblem();
  552. times--;
  553. if (Array.isArray(a) && a.length > 0) {
  554. handlerProblem(vue.toRaw(Object.assign({}, fromData)));
  555. addProcess();
  556. window.clearInterval(loadTimeId);
  557. }
  558. if (times == 0) {
  559. window.clearInterval(loadTimeId);
  560. }
  561. }, 500);
  562. }
  563. });
  564. const q1 = vue.ref(false);
  565. return (_ctx, _cache) => {
  566. const _component_el_button = vue.resolveComponent("el-button");
  567. const _component_el_progress = vue.resolveComponent("el-progress");
  568. const _component_el_divider = vue.resolveComponent("el-divider");
  569. const _component_el_input = vue.resolveComponent("el-input");
  570. const _component_el_col = vue.resolveComponent("el-col");
  571. const _component_el_form_item = vue.resolveComponent("el-form-item");
  572. const _component_el_switch = vue.resolveComponent("el-switch");
  573. const _component_el_tooltip = vue.resolveComponent("el-tooltip");
  574. const _component_el_form = vue.resolveComponent("el-form");
  575. const _component_el_dialog = vue.resolveComponent("el-dialog");
  576. const _component_el_row = vue.resolveComponent("el-row");
  577. const _component_el_link = vue.resolveComponent("el-link");
  578. const _component_el_table_column = vue.resolveComponent("el-table-column");
  579. const _component_el_table = vue.resolveComponent("el-table");
  580. const _component_el_drawer = vue.resolveComponent("el-drawer");
  581. return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
  582. vue.createElementVNode("div", null, [
  583. vue.createVNode(_component_el_button, {
  584. type: "primary",
  585. style: {},
  586. onClick: viewSetting,
  587. class: "m-setting-button m-button",
  588. circle: "",
  589. size: "large"
  590. }, {
  591. default: vue.withCtx(() => [
  592. vue.createTextVNode(" 0X3F ")
  593. ]),
  594. _: 1
  595. })
  596. ]),
  597. vue.createVNode(_component_el_drawer, {
  598. modelValue: drawer.value,
  599. "onUpdate:modelValue": _cache[17] || (_cache[17] = ($event) => drawer.value = $event),
  600. "with-header": false,
  601. size: "30%"
  602. }, {
  603. default: vue.withCtx(() => [
  604. vue.createElementVNode("div", _hoisted_1, [
  605. vue.createVNode(_component_el_progress, {
  606. type: "circle",
  607. percentage: finishProcess.value,
  608. color: processColors
  609. }, {
  610. default: vue.withCtx(({ percentage }) => [
  611. vue.createElementVNode("p", null, vue.toDisplayString(percentage) + "%", 1)
  612. ]),
  613. _: 1
  614. }, 8, ["percentage"])
  615. ]),
  616. vue.createElementVNode("p", _hoisted_2, vue.toDisplayString(vue.unref(finishProblem)) + " / " + vue.toDisplayString(vue.unref(totProblem)), 1),
  617. vue.createCommentVNode("", true),
  618. vue.createVNode(_component_el_divider),
  619. vue.createVNode(_component_el_form, {
  620. "label-position": "left",
  621. "label-width": "auto",
  622. model: fromData,
  623. style: { "max-width": "600px" }
  624. }, {
  625. default: vue.withCtx(() => [
  626. vue.createVNode(_component_el_form_item, { label: "分数区间" }, {
  627. default: vue.withCtx(() => [
  628. vue.createVNode(_component_el_col, { span: 10 }, {
  629. default: vue.withCtx(() => [
  630. vue.createVNode(_component_el_input, {
  631. modelValue: fromData.min,
  632. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => fromData.min = $event),
  633. "aria-placeholder": "",
  634. placeholder: " min "
  635. }, null, 8, ["modelValue"])
  636. ]),
  637. _: 1
  638. }),
  639. vue.createVNode(_component_el_col, {
  640. class: "text-center",
  641. span: 1,
  642. style: { "margin": "0 0.5rem" }
  643. }, {
  644. default: vue.withCtx(() => [
  645. vue.createTextVNode("-")
  646. ]),
  647. _: 1
  648. }),
  649. vue.createVNode(_component_el_col, { span: 10 }, {
  650. default: vue.withCtx(() => [
  651. vue.createVNode(_component_el_input, {
  652. modelValue: fromData.max,
  653. "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => fromData.max = $event),
  654. "aria-placeholder": "",
  655. placeholder: " max"
  656. }, null, 8, ["modelValue"])
  657. ]),
  658. _: 1
  659. })
  660. ]),
  661. _: 1
  662. }),
  663. vue.createVNode(_component_el_form_item, { label: "显示会员题" }, {
  664. default: vue.withCtx(() => [
  665. vue.createVNode(_component_el_switch, {
  666. modelValue: fromData.visiableMember,
  667. "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => fromData.visiableMember = $event)
  668. }, null, 8, ["modelValue"])
  669. ]),
  670. _: 1
  671. }),
  672. vue.createVNode(_component_el_form_item, { label: "隐藏AC题目" }, {
  673. default: vue.withCtx(() => [
  674. vue.createVNode(_component_el_switch, {
  675. modelValue: fromData.hiddenAc,
  676. "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => fromData.hiddenAc = $event)
  677. }, null, 8, ["modelValue"])
  678. ]),
  679. _: 1
  680. }),
  681. vue.createVNode(_component_el_form_item, { label: "收藏题单中生效" }, {
  682. default: vue.withCtx(() => [
  683. vue.createVNode(_component_el_tooltip, {
  684. content: "插件只在收藏题单中生效,刷新生效 ",
  685. placement: "bottom-end"
  686. }, {
  687. default: vue.withCtx(() => [
  688. vue.createVNode(_component_el_switch, {
  689. modelValue: fromData.onlyUrls,
  690. "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => fromData.onlyUrls = $event)
  691. }, null, 8, ["modelValue"])
  692. ]),
  693. _: 1
  694. })
  695. ]),
  696. _: 1
  697. }),
  698. vue.createVNode(_component_el_form_item, { label: "使用题单" }, {
  699. default: vue.withCtx(() => [
  700. vue.createVNode(_component_el_switch, {
  701. modelValue: fromData.useDefaultSetting,
  702. "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => fromData.useDefaultSetting = $event)
  703. }, null, 8, ["modelValue"])
  704. ]),
  705. _: 1
  706. })
  707. ]),
  708. _: 1
  709. }, 8, ["model"]),
  710. fromData.useDefaultSetting ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
  711. vue.createVNode(_component_el_divider),
  712. vue.createVNode(_component_el_button, {
  713. plain: "",
  714. onClick: showProblems
  715. }, {
  716. default: vue.withCtx(() => [
  717. vue.createTextVNode(" 查看收藏的题单 ")
  718. ]),
  719. _: 1
  720. }),
  721. vue.createVNode(_component_el_divider)
  722. ], 64)) : vue.createCommentVNode("", true),
  723. vue.createVNode(_component_el_button, {
  724. plain: "",
  725. onClick: _cache[8] || (_cache[8] = ($event) => q1.value = !q1.value)
  726. }, {
  727. default: vue.withCtx(() => [
  728. vue.createTextVNode(" 问题1 ")
  729. ]),
  730. _: 1
  731. }),
  732. vue.createVNode(_component_el_divider),
  733. vue.createVNode(_component_el_dialog, {
  734. modelValue: q1.value,
  735. "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => q1.value = $event),
  736. title: "关于查询状态会不会被封号 ?"
  737. }, {
  738. default: vue.withCtx(() => [
  739. vue.createVNode(Q1)
  740. ]),
  741. _: 1
  742. }, 8, ["modelValue"]),
  743. vue.createVNode(_component_el_dialog, {
  744. modelValue: dialogTableVisible.value,
  745. "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => dialogTableVisible.value = $event),
  746. title: "题单"
  747. }, {
  748. default: vue.withCtx(() => [
  749. vue.createVNode(_component_el_row, { gutter: 10 }, {
  750. default: vue.withCtx(() => [
  751. vue.createVNode(_component_el_col, { span: 8 }, {
  752. default: vue.withCtx(() => [
  753. vue.createVNode(_component_el_input, {
  754. modelValue: keywords.value,
  755. "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => keywords.value = $event),
  756. placeholder: "请输入关键词过滤",
  757. clearable: ""
  758. }, null, 8, ["modelValue"])
  759. ]),
  760. _: 1
  761. }),
  762. vue.createVNode(_component_el_col, { span: 16 }, {
  763. default: vue.withCtx(() => [
  764. vue.createVNode(_component_el_button, {
  765. plain: "",
  766. onClick: addlocal,
  767. disabled: isDisabbled.value
  768. }, {
  769. default: vue.withCtx(() => [
  770. vue.createTextVNode(" 添加本页 ")
  771. ]),
  772. _: 1
  773. }, 8, ["disabled"]),
  774. vue.createVNode(_component_el_button, {
  775. plain: "",
  776. onClick: _cache[11] || (_cache[11] = ($event) => handlerProblems("add"))
  777. }, {
  778. default: vue.withCtx(() => [
  779. vue.createTextVNode(" 自定义 ")
  780. ]),
  781. _: 1
  782. }),
  783. vue.createVNode(_component_el_button, {
  784. plain: "",
  785. onClick: handlerDefault
  786. }, {
  787. default: vue.withCtx(() => [
  788. vue.createTextVNode(" 默认 ")
  789. ]),
  790. _: 1
  791. })
  792. ]),
  793. _: 1
  794. })
  795. ]),
  796. _: 1
  797. }),
  798. vue.createVNode(_component_el_table, {
  799. data: urlsData.value,
  800. height: "300",
  801. style: { "width": "100%", "margin-top": "10px" }
  802. }, {
  803. default: vue.withCtx(() => [
  804. vue.createVNode(_component_el_table_column, {
  805. label: "标题",
  806. width: "auto",
  807. align: "center"
  808. }, {
  809. default: vue.withCtx((scope) => [
  810. vue.createVNode(_component_el_link, {
  811. href: scope.row.link,
  812. target: "_blank",
  813. type: "default"
  814. }, {
  815. default: vue.withCtx(() => [
  816. vue.createTextVNode(vue.toDisplayString(scope.row.title), 1)
  817. ]),
  818. _: 2
  819. }, 1032, ["href"])
  820. ]),
  821. _: 1
  822. }),
  823. vue.createVNode(_component_el_table_column, {
  824. label: "操作",
  825. width: "auto",
  826. align: "center"
  827. }, {
  828. default: vue.withCtx((scope) => [
  829. vue.createVNode(_component_el_button, {
  830. type: "primary",
  831. size: "small",
  832. onClick: ($event) => handlerProblems("update", scope.row, scope.$index)
  833. }, {
  834. default: vue.withCtx(() => [
  835. vue.createTextVNode("编辑")
  836. ]),
  837. _: 2
  838. }, 1032, ["onClick"]),
  839. vue.createVNode(_component_el_button, {
  840. type: "danger",
  841. size: "small",
  842. onClick: ($event) => deleteProblems(scope.$index)
  843. }, {
  844. default: vue.withCtx(() => [
  845. vue.createTextVNode("删除")
  846. ]),
  847. _: 2
  848. }, 1032, ["onClick"])
  849. ]),
  850. _: 1
  851. })
  852. ]),
  853. _: 1
  854. }, 8, ["data"])
  855. ]),
  856. _: 1
  857. }, 8, ["modelValue"]),
  858. vue.createVNode(_component_el_dialog, {
  859. modelValue: dialogFormVisible.value,
  860. "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => dialogFormVisible.value = $event),
  861. title: `${info.status == "add" ? "添加" : "编辑"}`,
  862. width: "400"
  863. }, {
  864. footer: vue.withCtx(() => [
  865. vue.createElementVNode("div", _hoisted_3, [
  866. vue.createVNode(_component_el_button, {
  867. onClick: _cache[15] || (_cache[15] = ($event) => dialogFormVisible.value = false)
  868. }, {
  869. default: vue.withCtx(() => [
  870. vue.createTextVNode("取消")
  871. ]),
  872. _: 1
  873. }),
  874. vue.createVNode(_component_el_button, {
  875. type: "primary",
  876. onClick: addOrUpdate
  877. }, {
  878. default: vue.withCtx(() => [
  879. vue.createTextVNode(" 确认 ")
  880. ]),
  881. _: 1
  882. })
  883. ])
  884. ]),
  885. default: vue.withCtx(() => [
  886. vue.createVNode(_component_el_form, null, {
  887. default: vue.withCtx(() => [
  888. vue.createVNode(_component_el_form_item, {
  889. label: "标题",
  890. "label-width": formLabelWidth
  891. }, {
  892. default: vue.withCtx(() => [
  893. vue.createVNode(_component_el_input, {
  894. modelValue: info.title,
  895. "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => info.title = $event),
  896. autocomplete: "off"
  897. }, null, 8, ["modelValue"])
  898. ]),
  899. _: 1
  900. }),
  901. vue.createVNode(_component_el_form_item, {
  902. label: "链接",
  903. "label-width": formLabelWidth
  904. }, {
  905. default: vue.withCtx(() => [
  906. vue.createVNode(_component_el_input, {
  907. modelValue: info.link,
  908. "onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => info.link = $event),
  909. autocomplete: "off"
  910. }, null, 8, ["modelValue"])
  911. ]),
  912. _: 1
  913. })
  914. ]),
  915. _: 1
  916. })
  917. ]),
  918. _: 1
  919. }, 8, ["modelValue", "title"])
  920. ]),
  921. _: 1
  922. }, 8, ["modelValue"])
  923. ], 64);
  924. };
  925. }
  926. };
  927. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-52bea08d"]]);
  928. const cssLoader = (e) => {
  929. const t = GM_getResourceText(e);
  930. return GM_addStyle(t), t;
  931. };
  932. cssLoader("elementPlusCss");
  933. const stopRankingKey = "__is_stop_rating_ranking__";
  934. let conetstTimeId = null;
  935. function run$1() {
  936. const container = document.querySelector(".contest-question-info .list-group");
  937. if (!container) return;
  938. const ls = Array.from(container.querySelectorAll(".list-group-item .pull-right"));
  939. for (let i = 0; i < 4; i++) {
  940. if (i >= ls.length) {
  941. break;
  942. }
  943. if (ls[i] instanceof HTMLElement) {
  944. ls[i].textContent = "0";
  945. }
  946. }
  947. window.clearInterval(conetstTimeId);
  948. }
  949. function startStopRanking() {
  950. if (!isContest(window.location.href)) {
  951. return;
  952. }
  953. const isNext = !!document.querySelector("#__next");
  954. if (isNext) {
  955. return;
  956. }
  957. const use = Cache$1.get(stopRankingKey);
  958. _GM_registerMenuCommand(`${use ? "使用" : "关闭"} 排行榜`, () => {
  959. Cache$1.set(stopRankingKey, !use);
  960. window.location.reload();
  961. }, { title: "对于不想看到排行榜的可以使用此功能 默认开启" });
  962. if (!use) {
  963. return;
  964. }
  965. conetstTimeId = setInterval(() => {
  966. run$1();
  967. }, 10);
  968. }
  969. const local_url = window.location.href;
  970. let loadID = 0;
  971. function run() {
  972. loadID++;
  973. if (isProblem(local_url) || isContest(local_url)) {
  974. if (isProblem(local_url)) {
  975. submitProblems(local_url);
  976. }
  977. setTimeout(() => {
  978. let submitbutton = null;
  979. const isNext = !!document.querySelector("#__next");
  980. if (isProblem(local_url) || isNext) {
  981. submitbutton = document.querySelector("div [data-e2e-locator=console-submit-button]");
  982. } else {
  983. let buttons = Array.from(document.querySelectorAll(".question-detail-bottom .pull-right button"));
  984. for (let i = buttons.length - 1; i >= 0; i--) {
  985. if (buttons[i].textContent.indexOf("提交解答") != -1) {
  986. submitbutton = buttons[i];
  987. break;
  988. }
  989. }
  990. }
  991. if (submitbutton) {
  992. submitbutton.addEventListener("click", () => {
  993. submitProblems(local_url);
  994. });
  995. } else if (loadID < 10) {
  996. run();
  997. }
  998. }, 3e3);
  999. } else if (isLeetCodeCircleUrl(local_url)) {
  1000. let Container = null;
  1001. let ok = Cache$1.get(__is_none_0x3f_problmes_button__, true, Boolean.name);
  1002. const start = () => {
  1003. Container = document.createElement("div");
  1004. const body = document.querySelector("body");
  1005. body.append(Container);
  1006. Container.style.display = ok && support_plugins() ? "block" : "none";
  1007. return Container;
  1008. };
  1009. let dom = start();
  1010. const VueApp = vue.createApp(App);
  1011. _GM_registerMenuCommand(`${ok ? "隐藏按钮" : "显示按钮"}`, () => {
  1012. ok = !ok;
  1013. Container.style.display = ok ? "block" : "none";
  1014. Cache$1.set(__is_none_0x3f_problmes_button__, ok);
  1015. }, { title: "可以手动关闭或者显示按钮 默认显示 刷新生效" });
  1016. _GM_registerMenuCommand(`${initObj().onlyUrls ? "仅在收藏题单页面生效" : "所有题单生效"}`, () => {
  1017. const u = initObj();
  1018. u.onlyUrls = !u.onlyUrls;
  1019. Container.style.display = support_plugins() ? "block" : "none";
  1020. Cache$1.set(__0x3f_problmes_solution__, u);
  1021. });
  1022. _GM_registerMenuCommand(`添加本页`, () => {
  1023. const urls = initUrls();
  1024. let ok2 = false;
  1025. let url = window.location.href;
  1026. for (let info of urls) {
  1027. if (!info || !(info == null ? void 0 : info.link)) {
  1028. continue;
  1029. }
  1030. if (info.link.indexOf(url) != -1) {
  1031. ok2 = true;
  1032. break;
  1033. }
  1034. }
  1035. if (ok2) {
  1036. ElementPlus.ElMessage({
  1037. message: "收藏失败,链接已经存在!",
  1038. type: "error"
  1039. });
  1040. } else {
  1041. if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) {
  1042. try {
  1043. url = url.split("view")[0];
  1044. } catch (e) {
  1045. url = window.location.href;
  1046. }
  1047. }
  1048. urls.unshift({
  1049. title: document.title,
  1050. link: url
  1051. });
  1052. Container.style.display = "block";
  1053. Cache$1.set(__0x3f_problmes_urls__, urls);
  1054. Cache$1.set(__0x3f_problmes_update__, true);
  1055. Cache$1.set(__add_cur__, true);
  1056. ElementPlus.ElMessage({
  1057. message: "收藏成功!刷新生效",
  1058. type: "success"
  1059. });
  1060. }
  1061. });
  1062. VueApp.use(ElementPlus).mount(dom);
  1063. }
  1064. }
  1065. run();
  1066. startStopRanking();
  1067.  
  1068. })(Vue, ElementPlus);