// ==UserScript== // @name 0x3f-problem-solution // @namespace https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution // @version 0.0.5.4 // @author wuxin0011 // @description 自定义分数区间显示题目 标记题目状态 配合灵茶山艾府题单解题 // @license MIT // @icon https://assets.leetcode.cn/aliyun-lc-upload/users/endlesscheng/avatar_1690721039.png // @source https://github.com/wuxin0011/tampermonkey-script/tree/main/0x3f-leetcode // @supportURL https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback // @match https://leetcode.cn/circle/discuss/* // @match https://leetcode.cn/problems/* // @match https://leetcode.cn/contest/*/problems/* // @match https://leetcode.com/circle/discuss/* // @match https://leetcode.com/discuss/* // @match https://leetcode.com/problems/* // @match https://leetcode.com/contest/*/problems/* // @require https://unpkg.com/vue@3.4.31/dist/vue.global.prod.js // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B // @require https://unpkg.com/element-plus@2.7.6/dist/index.full.js // @resource elementPlusCss https://unpkg.com/element-plus@2.7.6/dist/index.css // @grant GM_addStyle // @grant GM_deleteValue // @grant GM_getResourceText // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_setValue // ==/UserScript== (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const n=document.createElement("style");n.textContent=t,document.head.append(n)})(" h2[data-v-d1230ce3]{color:#000!important;margin:10px 0!important;font-size:20px!important}.m-setting-button[data-v-76dd1ba0]{position:fixed;top:200px;right:0;z-index:100000}.m-button[data-v-76dd1ba0]{margin-left:16px!important;padding:5px!important;font-size:14px!important}.processs-flex[data-v-76dd1ba0]{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} "); (function (ElementPlus, vue) { 'use strict'; var _GM_deleteValue = /* @__PURE__ */ (() => typeof GM_deleteValue != "undefined" ? GM_deleteValue : void 0)(); var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)(); var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)(); var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)(); let Cache$1 = class Cache2 { set(k, v) { _GM_setValue(k, v); } get(k, parse = true, name = String.name) { try { let v = _GM_getValue(k); switch (name) { case String.name: if (v == null) { return "null"; } return v; case Object.name: if (v == null || v == void 0 || typeof v != "object") { return {}; } return v; case Boolean.name: if (v === null || v == void 0) { return false; } if (v == false || v == "false" || v == "" || v == "null") { return false; } return v; case Array.name: if (v === null || v == void 0 || !Array.isArray(v)) { return []; } return v; default: return v; } } catch (E) { return null; } } remove(k) { _GM_deleteValue(k); } }; const Cache$2 = new Cache$1(); const width = 14; const height = 14; const bilibiliSVG = () => { return ` `; }; const problemContenst = () => ` `; const problemFinsh = () => ` `; const problemsTry = () => ` `; const problemsNo = () => install_pos() ? ` ` : ``; const createStatus = (status, link) => { var _a; let node; if (!link) { return; } const curUrl = (link == null ? void 0 : link.href) ?? ((_a = link.querySelector("a")) == null ? void 0 : _a.href); node = link instanceof HTMLAnchorElement ? link.parentElement : link; if (node) { node.status = status; } let installSVG = ""; if (isContest(curUrl)) { installSVG = problemContenst(); } else if (isLeetCodeCircleUrl(curUrl)) ; else if (isBilibili(curUrl)) { installSVG = bilibiliSVG(); } else { if (status == STATUS["AC"]) { installSVG = problemFinsh(); } else if (status == STATUS["notac"]) { installSVG = problemsTry(); } else if (status == STATUS["NO"]) { installSVG = problemsNo(); } } let svg = node.querySelector("svg"); if (svg) { if (svg.getAttribute("status") == status || svg.getAttribute("status") == STATUS["AC"]) { return false; } svg.remove(); } if (isBilibili(curUrl)) { node.innerHTML = node.innerHTML + " " + installSVG; } else { node.innerHTML = install_pos() ? installSVG + node.innerHTML : node.innerHTML + installSVG; } return true; }; const inf = 4e3; const mi = 1e3; const __0X3F_PROBLEM_KEYS__$1 = { "__0x3f_problmes_solution__": "__0x3f_problmes_solution__", // 基本信息 "__0x3f_problmes_urls__": "__0x3f_problmes_urls__", // 题单key "__0x3f_problmes_update__": "__0x3f_problmes_update__", // 是否修改了默认题单key "__0x3f_problmes_button_is_none__": "__is_none_0x3f_problmes_button__", // 是否隐藏设置按钮 "__0x3f_problmes_insert_pos__": "__0x3f_problmes_insert_pos__", // 安装位置 "__0x3f_problmes_status_update__": "__0x3f_problmes_status_update__", "__0x3f_problmes_plugin_load_ok__": "__0x3f_problmes_plugin_load_ok__", // 是否使用插件 "__0x3f_problmes_add_cur__": "__0x3f_problmes_add_cur__", // 添加 url "__0x3f_problmes_ac_key__": "__local_ok_problem_key__", // ac key "__0x3f_problmes_ac_version__": "__0x3f_problmes_ac_version__", // TODO ac key version "__0x3f_problmes_all_problems__": "__0x3f_problmes_all_problems__", // all problems "__0x3f_problmes_random_problems_key__": "__0x3f_problmes_random_problems_key__", //随机题目快捷键 "__0x3f_problmes_random_problems__": "__0x3f_problmes_random_problems__", //随机题目 "__0x3f_problme_support_type__": "__0x3f_problme_support_type__", //是否替换到com 默认cn "__0x3f_problme_support_type_tips__": "__0x3f_problme_support_type_tips__" //是否替换到com 默认cn 不再提示key }; const STATUS = { "AC": "ac", "NO": "null", "notac": "notac", "Accepted": "ac", "Wrong Answer": "notac" }; const defaultObj = { min: mi, max: inf, visiableMember: true, onlyUrls: false, useDefaultSetting: true, hiddenAc: false, showAcConfig: true, sortedType: 0 }; function install_pos() { return !Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_insert_pos__"], false, Boolean.name); } function isShow(text, min, max) { if (!text) { return true; } let res = text.match(/\d+/ig); if (!res) { return true; } if (Array.isArray(res) && res.length < 2) { return true; } let s = 0; for (let i = res.length - 1; i >= 0; i--) { s = res[i]; if (s >= mi && s <= inf) { return s >= min && s <= max; } } return true; } let A = void 0; const linkCssSelector_pre = () => isEnglishENV() ? ".discuss-markdown-container" : `#lc-content [class*="CollapsibleMarkdownContent"] [class*="MarkdownContent"]`; const linkCssSelector = `${linkCssSelector_pre()} li>a`; const queryProblem = () => Array.from(document.querySelectorAll(linkCssSelector)).filter((item) => item && item instanceof HTMLAnchorElement && (isProblem(item.href) || isContest(item.href))); function loadProblems() { A = queryProblem(); return A; } function handlerProblem(data) { var _a; try { loadProblems(); let { min, max, visiableMember, useDefaultSetting, onlyUrls, hiddenAc } = data; if (isNaN(min) || isNaN(max)) { min = mi; max = inf; } if (min < mi) { min = mi; } if (max < min) { max = inf; } min = Number(min); max = Number(max); data.min = min; data.max = max; Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"], data); for (let i = 0; i < A.length; i++) { if (!(A[i] instanceof HTMLAnchorElement)) { continue; } let d = (_a = A[i]) == null ? void 0 : _a.parentNode; if (!d) { continue; } let none = false; let Nohidden = isShow(d.textContent, min, max); d.style.display = Nohidden ? "" : "none"; if (!Nohidden) { continue; } if (hiddenAc) { const svg = d.querySelector("svg"); if (svg && svg.getAttribute("status")) { d.style.display = svg.getAttribute("status") == STATUS["AC"] ? "none" : ""; } } else { d.style.display = ""; } let c = d.textContent && d.textContent.indexOf("会员") != -1; if (!c) { continue; } d.style.display = visiableMember ? "" : "none"; } } catch (e) { console.log("error", e); } } function computeAcInfo(saveUrls = [], deleteOk = true) { let infos = []; let set = /* @__PURE__ */ new Set(); for (let i = 0, u = null; Array.isArray(saveUrls) && i < saveUrls.length; i++) { try { u = saveUrls[i]; if (!(u == null ? void 0 : u.link) || !(u == null ? void 0 : u.title) || !(u == null ? void 0 : u.id) || set.has(u.link)) { continue; } if (u["select"] == void 0) u.select = true; if (u["loading"] == void 0 || u["loading"]) u["loading"] = false; let s = Object.values(u).join(""); if (s == "null" || !Cache$2.get(u.link) || !getAcCountKey(u.link) || !Cache$2.get(getAcCountKey(u.link))) { continue; } let o = Cache$2.get(getAcCountKey(u.link)); u["ac"] = isNaN(o["ac"]) ? 0 : parseInt(o["ac"]); u["tot"] = isNaN(o["tot"]) ? 0 : parseInt(o["tot"]); set.add(u.link); } catch (e) { } infos.push(Object.assign({}, u)); } if (deleteOk) { for (let i = 0; i < saveUrls[i]; i++) { delete saveUrls[i]; } for (let info of infos) { saveUrls.push(info); } } return infos; } const initUrls = () => { let saveUrls = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_update__"], true, Boolean.name) ? Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_urls__"], true, Array.name) : defaultUrls; return computeAcInfo(saveUrls); }; const initObj = () => { let obj = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"]) ? Object.assign(defaultObj, Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_solution__"])) : defaultObj; if (obj["showAcConfig"] == null || obj["showAcConfig"] == void 0) { obj.showAcConfig = true; } if (obj["sortedType"] == null || obj["sortedType"] == void 0) { obj.sortedType = 0; } let temp = {}; for (let key of Object.keys(obj)) { if (!isNaN(key) || defaultObj[`${key}`] == void 0) continue; temp[`${key}`] = obj[`${key}`]; } return temp; }; const support_plugins = () => { const u = initObj(); if (!u || !u.onlyUrls) return true; let url = window.location.href; if (isLeetCodeCircleUrl(url) && url.indexOf("view") != -1) { try { url = url.split("view")[0]; } catch (e) { url = window.location.href; } } const urls = initUrls(); for (let info of urls) { if (!info || !(info == null ? void 0 : info.link)) { continue; } if (info.link.indexOf(url) != -1) { return true; } } return false; }; const defaultUrls = [ { "title": "数学算法(数论/组合/概率期望/博弈/计算几何/随机算法", "link": "https://leetcode.cn/circle/discuss/IYT3ss/", "tot": 0, "ac": 0, "id": 1, "disabled": false, "select": true }, { "title": "常用数据结构(前缀和/差分/栈/队列/堆/字典树/并查集/树状数组/线段树)", "link": "https://leetcode.cn/circle/discuss/mOr1u6/", "tot": 0, "ac": 0, "id": 2, "disabled": false, "select": true }, { "title": "动态规划(入门/背包/状态机/划分/区间/状压/数位/树形/数据结构优化)", "link": "https://leetcode.cn/circle/discuss/tXLS3i/", "tot": 0, "ac": 0, "id": 3, "disabled": false, "select": true }, { "title": "图论算法(DFS/BFS/拓扑排序/最短路/最小生成树/二分图/基环树/欧拉路径)", "link": "https://leetcode.cn/circle/discuss/01LUak/", "tot": 0, "ac": 0, "id": 4, "disabled": false, "select": true }, { "title": "位运算(基础/性质/拆位/试填/恒等式/贪心/脑筋急转弯)", "link": "https://leetcode.cn/circle/discuss/dHn9Vk/", "tot": 0, "ac": 0, "id": 5, "disabled": false, "select": true }, { "title": "网格图(DFS/BFS/综合应用)", "link": "https://leetcode.cn/circle/discuss/YiXPXW/", "tot": 0, "ac": 0, "id": 6, "disabled": false, "select": true }, { "title": "单调栈(矩形面积/贡献法/最小字典序", "link": "https://leetcode.cn/circle/discuss/9oZFK9/", "tot": 0, "ac": 0, "id": 7, "disabled": false, "select": true }, { "title": "二分算法(二分答案/最小化最大值/最大化最小值/第K小", "link": "https://leetcode.cn/circle/discuss/SqopEo/", "tot": 0, "ac": 0, "id": 8, "disabled": true, "select": true }, { "title": "滑动窗口(定长/不定长/多指针", "link": "https://leetcode.cn/circle/discuss/0viNMK/", "tot": 0, "ac": 0, "id": 9, "disabled": false, "select": true }, { "title": "贪心算法(基本贪心策略/反悔/区间/字典序/数学/思维/构造)", "link": "https://leetcode.cn/circle/discuss/g6KTKL/", "tot": 0, "ac": 0, "id": 10, "disabled": false, "select": true }, { "title": "链表、二叉树与一般树(前后指针/快慢指针/DFS/BFS/直径/LCA)", "link": "https://leetcode.cn/circle/discuss/K0n2gO/", "tot": 0, "ac": 0, "id": 11, "disabled": false, "select": true }, { "title": "字符串(KMP/Z函数/Manacher/字符串哈希/AC自动机/后缀数组/子序列自动机)", "link": "https://leetcode.cn/circle/discuss/SJFwQI/", "tot": 0, "ac": 0, "id": 12, "disabled": false, "select": true } // { 'title': '灵茶题单完成情况', 'link': 'https://leetcode.cn/u/endlesscheng/', 'tot': 0, 'ac': 0, 'id': 0x3f3f3f3f,'disabled':true,'select':false }, ]; function getId(problemUrl) { if (isContest(problemUrl) || isProblem(problemUrl)) { try { return problemUrl.split("problems")[1].split("/")[1]; } catch (e) { return ""; } } return ""; } function postData(ID2) { return { "query": "\n query userQuestionStatus($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n status\n }\n}\n ", "variables": { "titleSlug": ID2 }, "operationName": "userQuestionStatus" }; } async function queryStatus(ID2 = "", cache = {}, cur = void 0, watch2 = false) { var _a, _b, _c; if (!ID2) { return; } if (cache[ID2] == void 0 || cache[ID2] != STATUS["AC"]) { const response = await getProblemAcInfo(ID2); if (isDev()) { console.log("query result response:", response); } if ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.question) { const status = (_c = (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.question) == null ? void 0 : _c.status; if (cache[ID2] == void 0 || cache[ID2] != status) { cache[ID2] = status == null ? "null" : status; if (watch2) { if (isDev()) { console.log("save local status :", cache[ID2], "status = ", status, "get local status :", Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"])[ID2]); } watchSaveStatus(ID2, cache[ID2]); } createStatus(cache[ID2], cur); } } else { console.warn("query result is undefined"); createStatus(cache[ID2], cur); } } } async function addProcess(reload = true, doms = void 0, asyncAc = false) { var _a; let problems_doms = Array.isArray(doms) ? doms : loadProblems(); const cache = getLocalProblemStatus(); let uid = 0, query_cnt = 0; const isReplaceEnglish = isEnglish(); for (let i = 0; i < problems_doms.length; i++) { let cur = problems_doms[i].parentElement; if (!(cur instanceof HTMLElement)) { continue; } const ID2 = getId((_a = problems_doms[i]) == null ? void 0 : _a.href); if (!ID2) { continue; } if (install_pos()) { cur.style.listStyleType = "none"; } if (isReplaceEnglish && problems_doms[i].href) { problems_doms[i].href = problems_doms[i].href.replace("leetcode.cn", "leetcode.com"); } if (!cache[ID2] || cache[ID2] != STATUS["AC"] && asyncAc) { await sleep(50); await queryStatus(ID2, cache, cur, false); query_cnt++; if (query_cnt % 10 == 0) { Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], cache); } } else { let status = cache[ID2]; uid++; createStatus(status, cur); } } if (isDev()) { console.log("cache num :", uid, ",tot:", A.length); } getProcess(); Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], cache); let other = Array.from(document.querySelectorAll(`${linkCssSelector_pre()} p>a`)).filter((item) => item && item instanceof HTMLAnchorElement && isBilibili(item.href)); for (let i = 0; i < other.length; i++) { createStatus("null", other[i]); } } const submitProblems = (url = window.location.href, timeout = 500) => { const ID2 = getId(url); if (!ID2) { return; } setTimeout(() => { const cache = getLocalProblemStatus(); console.log("ID:", ID2, "query status: ", cache[ID2]); queryStatus(ID2, cache, void 0, true); }, timeout); }; const watchSaveStatus = (ID2, status) => { const cache = getLocalProblemStatus(); if (cache[ID2] != "ac") { cache[ID2] = status; Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], cache); window.localStorage.setItem(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_status_update__"], JSON.stringify({ "id": ID2, "status": status })); } }; const watchLinkStatusUpdate = (e) => { var _a; if (e.key != __0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_status_update__"]) { return; } let { id, status } = JSON.parse(e.newValue); if (!id || !status) { return; } let thisLink = `${CUR_URL}/problems/${id}`; if (isDev()) { console.log("update", thisLink, "status", status); } let link = document.querySelector(`${linkCssSelector}[href^="${CUR_URL}/problems/${id}"]`); if (!link || !(link == null ? void 0 : link.parentElement)) { let doms = loadProblems(); for (let i = 0; i < doms.length; i++) { if (!doms[i] || !((_a = doms[i]) == null ? void 0 : _a.parentElement)) { continue; } if (doms[i].href.indexOf(thisLink) != -1) { link = doms[i]; break; } } } createStatus(status, link); }; function getAcCountKey(k) { if (!k) return ""; return `0x3f_ac_key_${k}`; } function deleteAllACCountKeys() { let urls = initUrls(); let keys = []; for (let urlInfo of urls) { let key = getAcCountKey(urlInfo.link); Cache$2.remove(key); keys.push(key); } Cache$2.remove(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"]); return keys; } async function getProcess() { var _a; loadProblems(); const cache = getLocalProblemStatus(); const config = initObj(); const response = await githubProblem(true); const mapInfo = response[1]; let cnt = 0; let tot = 0; for (let i = 0; i < A.length; i++) { let ID2 = getId(A[i].href); if (!(config == null ? void 0 : config.visiableMember) && ((_a = mapInfo.get(ID2)) == null ? void 0 : _a.member)) { continue; } if (ID2 && cache[ID2] == STATUS["AC"]) { cnt++; } tot++; } let url = window.location.href; if (A.length > 0 && getAcCountKey(url)) { Cache$2.set(getAcCountKey(url), { "tot": tot, "ac": cnt }); } return [cnt, tot]; } function getLocalProblemStatus() { return Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name); } function getRandomInfo(array) { if (!Array.isArray(array)) return void 0; return array[Math.floor(Math.random() * array.length)]; } function isEnglish() { return Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type__"], Boolean.name) == true; } function changeEnglishType() { Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type__"], !isEnglish()); if (Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"], String.name) != "NO") { Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"], "OK"); } window.location.reload(); } function installEnglishLinkChangeCommand() { if (!isLeetCodeCircleUrl() || isEnglishENV()) { return; } _GM_registerMenuCommand(`题目链接切换到${isEnglish() ? "国服🎈" : "美服🌎"}`, () => { changeEnglishType(); }, { title: "将题单链接替换为国服或者替换为美服" }); } async function githubProblem(not_filter_member = true) { let allProbmems; if (!Array.isArray(allProbmems) || allProbmems.length == 0) { let response = await getProblemsJSON(); if (Array.isArray(response)) { allProbmems = [...response]; Cache$2.set(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_all_problems__"], [...response]); } } else { allProbmems = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_all_problems__"], true, Array.name); } if (!Array.isArray(allProbmems)) { ElementPlus.ElMessage({ type: "error", message: "随机题目失败获取不到任何信息 !请如果出现这种情况,请前往 https://github.com/wuxin0011/tampermonkey-script/issues 反馈", duration: 6e3 }); return; } let config = initObj(); let urlsData = initUrls(); let set = /* @__PURE__ */ new Set(); for (let info of urlsData) { if (info.link && info.select) { set.add(info.link); } } let acMap = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name); if (isDev()) { console.log("config and set", config, set); console.log("acMap", acMap); } let infos = []; let mapInfo = /* @__PURE__ */ new Map(); let totInfo = []; for (let info of allProbmems) { if (!(info == null ? void 0 : info.problemUrl) || !set.has(info == null ? void 0 : info.problemUrl) || !Array.isArray(info.problems) || info.problems.length == 0) { continue; } let cur_infos = []; for (let i = 0; Array.isArray(info.problems) && i < info.problems.length; i++) { try { let { title, url, member, score, titleSlug } = info.problems[i]; if (!url || !title) continue; if (!(config == null ? void 0 : config.visiableMember) && member || !not_filter_member && member) { continue; } let new_obj = { title, url, member, score, titleSlug, "status": acMap[titleSlug] }; infos.push(new_obj); cur_infos.push(new_obj); mapInfo.set(titleSlug, new_obj); } catch (e) { console.log("error", e); } } info.problems = cur_infos; totInfo.push(info); } return [infos, mapInfo, totInfo]; } async function randomProblem() { let responseDatas = await githubProblem(); let acMap = Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problmes_ac_key__"], true, Object.name); let config = initObj(); let problems = responseDatas[0]; let infos = []; for (let i = 0; Array.isArray(problems) && i < problems.length; i++) { try { let { title, url, member, score, titleSlug } = problems[i]; if (!url || !title) continue; if (isDev()) { } if (!(config == null ? void 0 : config.showAcConfig) && acMap[titleSlug] == "ac") { continue; } if (!(config == null ? void 0 : config.visiableMember) && member) { continue; } if (score != 0 && (score < (config == null ? void 0 : config.min) || score > (config == null ? void 0 : config.max))) { continue; } infos.push({ title, url, member, score, titleSlug, "status": acMap[titleSlug] }); } catch (e) { console.log("error", e); } } let data = getRandomInfo(infos); if (data.url && isEnglish()) { data.url = data.url.replace(ZH_URL, EN_URL); } ElementPlus.ElMessage({ dangerouslyUseHTMLString: !!(data && (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title)), type: (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title) ? "success" : "error", message: (data == null ? void 0 : data.url) && (data == null ? void 0 : data.title) ? `
随机题目☕: ${data.title} ${(data == null ? void 0 : data.score) && (data == null ? void 0 : data.score) > 0 ? ` 分值${data.score}` : ""}
` : `没有符合条件的题目,请重新配置条件!`, duration: 6e3 }); } function isEnglishENV() { return window.location.href.indexOf("https://leetcode.com") != -1; } const isHttp = (url) => /^https?:\/\/.*$/.test(url); const isLeetCodeCircleUrl = (url = window.location.href) => /^https?:\/\/leetcode\.(com|cn).*\/discuss\/.*/i.test(url); const isProblem = (url = window.location.href) => /^https?:\/\/leetcode\.(com|cn)\/problems\/.*/i.test(url); const isContest = (url = window.location.href) => /^https?:\/\/leetcode\.(com|cn)\/contest\/.*\/problems\/.*/.test(url); const isBilibili = (url = window.location.href) => /.*bilibili.*/.test(url); const isZH = (url = window.location.href) => /^https?:\/\/leetcode\.cn/.test(url); const sleep = async (time = 500) => new Promise((resolove) => setTimeout(resolove, time)); const EN_URL = "https://leetcode.com"; const ZH_URL = "https://leetcode.cn"; const LC_COPY_HTML_PLUGIN = "https://greasyfork.org/zh-CN/scripts/491969-lc-to-markdown-txt-html"; const EN_SOLUTION_DEMO = "https://leetcode.com/discuss/interview-question/6032972/leetcode"; const CUR_URL = isEnglishENV() ? EN_URL : ZH_URL; const isDev = () => JSON.parse("false"); async function GetHubJSONInfo(url) { return fetch(url, { method: "get", mode: "cors" }).then((res) => res.json()); } async function getProblemsJSON() { return GetHubJSONInfo("https://raw.githubusercontent.com/wuxin0011/tampermonkey-script/main/0x3f-leetcode/0x3f.json"); } const LEETCODE_PROBLEM_API = `${CUR_URL}/graphql/`; async function PostLeetCodeApi(data) { return fetch(LEETCODE_PROBLEM_API, { method: "POST", credentials: "include", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) }).then((res) => res.json()); } async function getProblemAcInfo(titleSlug) { return PostLeetCodeApi(postData(titleSlug)); } const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; const _sfc_main$1 = {}; const _withScopeId = (n) => (vue.pushScopeId("data-v-d1230ce3"), n = n(), vue.popScopeId(), n); const _hoisted_1$1 = /* @__PURE__ */ vue.createStaticVNode('

🎈必读内容

❓ 题单进度不一致

❓ 如何使用随机题目?

❓ 如何使用美服

', 7); const _hoisted_8 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("h2", null, " 🔗 反馈更新 ", -1)); function _sfc_render(_ctx, _cache) { const _component_el_link = vue.resolveComponent("el-link"); return vue.openBlock(), vue.createElementBlock("div", null, [ _hoisted_1$1, vue.createElementVNode("ul", null, [ vue.createElementVNode("li", null, [ vue.createTextVNode(" 处于网络安全策略,对于不同网站请求有 "), vue.createVNode(_component_el_link, { underline: false, href: "https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS", type: "primary", target: "_blank" }, { default: vue.withCtx(() => [ vue.createTextVNode("跨域机制保护") ]), _: 1 }), vue.createTextVNode(" 美服和国服是两个不同网站,因此无法实现不同网站题单同步 。 ") ]), vue.createElementVNode("li", null, [ vue.createTextVNode(" 如果想使用美服,请复制一份题单到美服中 "), vue.createVNode(_component_el_link, { underline: false, href: "https://greasyfork.org/zh-CN/scripts/491969-lc-to-markdown-txt-html", type: "primary", target: "_blank" }, { default: vue.withCtx(() => [ vue.createTextVNode("lc-to-markdown-txt-html") ]), _: 1 }), vue.createTextVNode(" 这个插件来复制题单 ") ]), vue.createElementVNode("li", null, [ vue.createVNode(_component_el_link, { underline: false, href: "https://leetcode.com/discuss/interview-question/6032972/leetcode", type: "primary", target: "_blank" }, { default: vue.withCtx(() => [ vue.createTextVNode("美服题单演示") ]), _: 1 }) ]) ]), _hoisted_8, vue.createElementVNode("ul", null, [ vue.createElementVNode("li", null, [ vue.createTextVNode(" 你可以在 "), vue.createVNode(_component_el_link, { underline: false, href: "https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback", type: "success", target: "_blank" }, { default: vue.withCtx(() => [ vue.createTextVNode("油猴") ]), _: 1 }), vue.createTextVNode("   "), vue.createVNode(_component_el_link, { underline: false, href: "https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback", type: "success", target: "_blank" }, { default: vue.withCtx(() => [ vue.createTextVNode("脚本猫") ]), _: 1 }), vue.createTextVNode(" 中更新或下载 ") ]), vue.createElementVNode("li", null, [ vue.createVNode(_component_el_link, { underline: false, href: "https://greasyfork.org/zh-CN/scripts/501134-0x3f-problem-solution/feedback", type: "primary", target: "_blank" }, { default: vue.withCtx(() => [ vue.createTextVNode("点击") ]), _: 1 }), vue.createTextVNode("这里反馈 或者 "), vue.createVNode(_component_el_link, { target: "_blank", underline: false, href: "https://github.com/wuxin0011/tampermonkey-script/issues", type: "primary" }, { default: vue.withCtx(() => [ vue.createTextVNode("issues") ]), _: 1 }) ]) ]) ]); } const Q1 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-d1230ce3"]]); function Message(title = "确认操作", callback = () => { }, canlcelCallback = () => { }) { ElementPlus.ElMessageBox.confirm( `${title} ?`, "警告", { confirmButtonText: "确认", cancelButtonText: "取消", type: "warning" } ).then(() => { callback(); }).catch(() => { ElementPlus.ElMessage({ type: "info", message: "已取消" }); canlcelCallback(); }); } function tips_message() { if (isEnglish() && isZH() && Cache$2.get(__0X3F_PROBLEM_KEYS__$1["__0x3f_problme_support_type_tips__"]) == "OK") { ElementPlus.ElMessageBox.alert( `

检查到当前环境为国服,如果需要同步功能需要切换到美服,或者复制一份题单到美服自己使用 否则仅保留替换链接功能,没有同步功能