LeetCode Problem Jumper

在 LeetCode 题目页面支持直接根据题号跳转到题目。Jump from one problem to another problem directly!

2024-10-24 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         LeetCode Problem Jumper
// @namespace    https://github.com/ipdor/LeetCodeProblemJumper
// @version      1.0
// @description  在 LeetCode 题目页面支持直接根据题号跳转到题目。Jump from one problem to another problem directly!
// @author       ipdor
// @match        https://leetcode.com/problems/*
// @match        https://leetcode.cn/problems/*
// @grant        none
// @license      MIT 
// ==/UserScript==

(function(){"use strict";function getElementByXPath(xpath){const result=document.evaluate(xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);return result.singleNodeValue}function addJumpButton(){const targetDiv=getElementByXPath("/html/body/div[1]/div[2]/div/div/div[3]/nav/div/div/div[1]");if(targetDiv){if(!document.getElementById('problem_no')){const newDiv=document.createElement('div');newDiv.innerHTML='<input id="problem_no" type="text" placeholder="输入题号"><button id="jump_to_problem">跳转</button>';targetDiv.insertAdjacentElement('beforeend',newDiv);document.getElementById('jump_to_problem').addEventListener('click',function(){const problemNo=document.getElementById('problem_no').value.trim();if(problemNo&&!isNaN(problemNo)){window.location.href=`https://lcid.cc/${problemNo}`}else{alert('请输入有效的题号!')}})}}else{console.error('未找到指定的 XPath 位置。')}}const observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.addedNodes.length>0){addJumpButton()}})});observer.observe(document.body,{childList:true,subtree:true});addJumpButton()})();