Greasy Fork is available in English.

Discord Hide Channel List Button

Hides the channel list at the press of a button

Version vom 31.05.2018. Aktuellste Version

// ==UserScript==
// @name         Discord Hide Channel List Button
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Hides the channel list at the press of a button
// @author       20kdc
// @match        https://discordapp.com/channels/*
// @grant        none
// ==/UserScript==

// I release this user-script into the public domain.

var mainFunc;
var lastTryParent;
mainFunc = function() {
    'use strict';
    // Toolbar instance tends to change
    setTimeout(mainFunc, 5000);
    const vChat = document.querySelector(".chat");
    if (!vChat)
        return;
    const v = vChat.firstChild.firstChild.lastChild;
    if (lastTryParent == v)
        return;
    lastTryParent = v;
    const d = document.createElement("img");
    d.draggable = false;
    d.src = "/assets/a860a4e9c04e5cc2c8c48ebf51f7ed46.svg";
    // Unscalable, but Discord does it too
    d.width = 24;
    d.height = 24;
    v.appendChild(d);
    
    var toggleState = true;
    d.addEventListener("click", () => {
        const v2a = document.querySelector(".chat");
        if (!v2a)
            return;
        const v2 = v2a.parentNode.firstChild;
        toggleState = !toggleState;
        if (toggleState) {
            d.class = "active";
            v2.style.display = "inherit";
        } else {
            d.class = "";
            v2.style.display = "none";
        }
    });
};
mainFunc();