LeetCode solution article widener

Add a toggle to widen the solution articles to view long code easier.

Stan na 12-12-2022. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         LeetCode solution article widener
// @namespace    https://github.com/zica87/self-made-userscipts
// @version      1.0
// @description  Add a toggle to widen the solution articles to view long code easier.
// @author       zica
// @match        https://leetcode.com/problems/*/solutions/*/*/
// @grant        none
// @license      GPL-2.0
// ==/UserScript==

(function() {
    'use strict';

    const toggle = document.createElement('button');
    toggle.innerText = '←→';
    Object.assign(toggle.style, {
        color: 'white',
        backgroundColor: 'rgb(40 40 40)',
        borderRadius: '0.75rem',
        padding: '1em',
        fontSize: '110%',
        fontWeight: 'bold',
        zIndex: '999',
        position: 'fixed',
        bottom: '5vh',
        right: '2vw',
    });
    toggle.onclick = ()=>{
        if (toggle.innerText === '←→'){
            document.getElementsByClassName('lc-lg:w-[250px]')[0].hidden = true;
            document.getElementsByClassName('max-w-[1020px]')[0].style.maxWidth = 'none';
            document.getElementsByClassName('lc-lg:max-w-[700px]')[0].style.maxWidth = 'none';
            toggle.innerText = 'Default';
        }
        else{
            document.getElementsByClassName('max-w-[1020px]')[0].style = '1020px';
            document.getElementsByClassName('lc-lg:max-w-[700px]')[0].style.maxWidth = '700px';
            document.getElementsByClassName('lc-lg:w-[250px]')[0].hidden = false;
            toggle.innerText = '←→';
        }
    };
    document.body.appendChild(toggle);
})();