Greasy Fork is available in English.

LeetCode Problem Jumper

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

Από την 24/10/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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()})();