🎉 欢迎访问GreasyFork镜像站!本站由公众号【爱吃馍】维护。 联系邮箱📮
💡 当前页面为缓存版本 (获取时间: 2025/12/22 12:47:00)。新内容正在后台静默同步中...

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

Leetcode invisible

A script to hide Leetcode question difficultly

Od 19.01.2021.. Pogledajte najnovija verzija.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

安装遇到问题?关注公众号【爱吃馍】获取帮助

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.

(I already have a user style manager, let me install it!)

安装遇到问题?关注公众号【爱吃馍】获取帮助

// ==UserScript==
// @name         Leetcode invisible
// @version      0.2
// @description  A script to hide Leetcode question difficultly
// @author       osjobs.nett
// @match        https://leetcode.com/*
// @match        https://leetcode-cn.com/*
// @exclude      https://leetcode-cn.com/problems/*/solution/
// @exclude      https://leetcode.com/problems/*/discuss/*
// @grant        none
// @namespace https://greasyfork.org/users/555531
// ==/UserScript==


// Since Leetcode use Ajax to load content,
// we have to check the label in first few seconds
if (window.location.href.indexOf("problemset") > -1) {
    var problemsetTimer = setInterval(problemsetFunction, 2000);
} else if (window.location.href.indexOf("problems") > -1) {
    var updateTime = 0;
    var problemTimer = setInterval(problemFunction, 100);
}


function problemsetFunction() {
    // Problems list page
    if(document.querySelector("span.label-warning")|| document.querySelector("span.label-success") || document.querySelector("span.label-danger") ) {
        var elementE = document.querySelectorAll("span.label-success");
        var elementM = document.querySelectorAll("span.label-warning");
        var elementH = document.querySelectorAll("span.label-danger");
        update(elementE, "label-success");
        update(elementM, "label-warning");
        update(elementH, "label-danger");
    };

    if(document.querySelector("span.level-easy")|| document.querySelector("span.level-medium") || document.querySelector("span.level-hard") ) {
        var elementCE = document.querySelectorAll("span.level-easy");
        var elementCM = document.querySelectorAll("span.level-medium");
        var elementCH = document.querySelectorAll("span.level-hard");
        update(elementCE, "level-easy");
        update(elementCM, "level-medium");
        update(elementCH, "level-hard");
    }
}

function problemFunction () {
    if (updateTime > 0) {
        clearInterval(problemTimer);
    }
    if(document.querySelector("div.css-1e1vffy-Tools")) {
        document.getElementsByClassName("css-1e1vffy-Tools")[0].style.display = "none";
        updateTime += 1;
    }
    if(document.querySelector("div.difficulty__ES5S")) {
        var similar_element = document.getElementsByClassName("difficulty__ES5S");
        for (var i=0; i<similar_element.length; i++) {
            similar_element[i].textContent = "Unknown";
        }
    }
}

function update(element, classname) {
    for (var i=0; i < element.length; i++) {
        element[i].classList.remove(classname);
        element[i].textContent = "Unknown";
    }
}