Leetcode solution screenshot helper

try to take over the world!

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Leetcode solution screenshot helper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Heyi
// @match        https://leetcode.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function removeElementsByClass(className){
        var elements = document.getElementsByClassName(className);
        while(elements.length > 0){
            elements[0].parentNode.removeChild(elements[0]);
        }
    }

    var sDown = false;
    var hDown = false;
    document.addEventListener('keydown', function(event) {
        switch (event.keyCode) {
            case 83:
                sDown = true;
                break;
            case 72:
                hDown = true;
                break;
            case 89:
                if (sDown && hDown) {
                    removeElementsByClass("header__3STC");
                    removeElementsByClass("css-5wdlwo-TabViewHeader");
                    removeElementsByClass("nav__1n5p");
                }
        }
    });
    document.addEventListener('keyup', function(event) {
        switch (event.keyCode) {
            case 83:
                sDown = false;
                break;
            case 72:
                hDown = false;
                break;
        }
    });

})();