Greasy Fork is available in English.

力扣屏蔽单题难度标签

力扣屏蔽单题难度标签~

// ==UserScript==
// @name         力扣屏蔽单题难度标签
// @namespace    markshawn.com
// @version      0.2
// @description  力扣屏蔽单题难度标签~
// @author       markshawn2020
// @match        https://leetcode.cn/problems/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=leetcode.cn
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let getLevelEle = () => document.querySelector("#qd-content > div.h-full.flex-col.ssg__qd-splitter-primary-w > div > div.min-h-0.flex-grow > div > div.flex.h-full.w-full.overflow-y-auto > div > div > div.w-full.px-5.pt-4 > div > div.mt-3.flex.space-x-4 > div");

    let checkLevelEle = () => {
        let levelEle = getLevelEle();
        if(levelEle) levelEle.style.display = 'none';
        console.log(`checking level ele: ${levelEle ? "OK" : "FAILED"}`);
        return levelEle;
    }

    // ref: https://stackoverflow.com/a/67825703
    const observer = new MutationObserver(function(mutations) {
        // TODO: add more conditions to avoid unnecessary check
        checkLevelEle();
    });
    const config = {subtree: true, childList: true};
    observer.observe(document, config);

    // init, loop
    let check = () => setTimeout(() => {
        if(!checkLevelEle()) check();
    }, 100);
    check();
})();