YouTube - Old Proper Description

Description below the video with proper open/close toggle, instead of a side bar.

נכון ליום 26-02-2022. ראה הגרסה האחרונה.

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 or Violentmonkey 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         YouTube - Old Proper Description
// @namespace    q1k
// @version      0.0.1b
// @description  Description below the video with proper open/close toggle, instead of a side bar.
// @author       q1k
// @match        *://www.youtube.com/*
// @grant        none
// @run-at       document-body
// ==/UserScript==

function waitForElement(selector) {
    return new Promise(function(resolve) {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }
        const observer = new MutationObserver(function(mutations) {
            if (document.querySelector(selector)) {
                resolve(document.querySelector(selector));
                observer.disconnect();
            }
        });
        observer.observe(document, {
            childList: true,
            subtree: true
        });
    });
}

function descriptionToggleButton(e){
    let parent = e.target.closest("ytd-expander");
    parent.collapsed = !parent.collapsed;
    if(parent.collapsed){
        morelabel.innerHTML = "Show More";
        lesslabel.innerHTML = "Show More";
    } else {
        morelabel.innerHTML = "Show Less";
        lesslabel.innerHTML = "Show Less";
    }
    e.target.blur();
    e.preventDefault();
    e.stopPropagation();
    e.stopImmediatePropagation();
}

var more, morelabel, less, lesslabel;
var added=false;
function addSTUFF(){
    if(added){ return; } else { added=true; }
    more = document.querySelector("ytd-expander #content ~ tp-yt-paper-button#more");
    morelabel = more.querySelector("yt-formatted-string");
    morelabel.innerHTML = "Show More";
    more.addEventListener('click',function(e){
        descriptionToggleButton(e);
    },true);

    less = document.querySelector("ytd-expander #content ~ tp-yt-paper-button#less yt-formatted-string");
    lesslabel = more.querySelector("yt-formatted-string");
    lesslabel.innerHTML = "Show More";
    less.addEventListener('click',function(e){
        descriptionToggleButton(e);
    },true);

    var styles = document.createElement("style");
    styles.innerHTML=`
#meta-contents[hidden], #info-contents[hidden]{ display: block !important; }
#primary #meta #more, #primary #meta #less { width: 100%; border-top: 1px solid; border-radius: 0; margin-top: 1em; background: linear-gradient(rgba(0,0,0,0.02), transparent); }
[dark] #primary #meta #more, [dark] #primary #meta #less { background: linear-gradient(rgba(255,255,255,0.02), transparent); }
#primary #meta #more yt-formatted-string, #primary #meta #less yt-formatted-string { margin: 0; padding: 4px; }
#primary #meta #more:hover, #primary #meta #less:hover { background: rgba(0,0,0,0.03); }
[dark] #primary #meta #more:hover, [dark] #primary #meta #less:hover { background: rgba(255,255,255,0.03); }
ytd-video-secondary-info-renderer, #primary #meta #more, #primary #meta #less { border-color: rgba(0,0,0,0.125); padding-bottom: 0; border-bottom: none; }
[dark] ytd-video-secondary-info-renderer, [dark] #primary #meta #more, [dark] #primary #meta #less { border-color: rgba(255,255,255,0.125); padding-bottom: 0; border-bottom: none; }
#meta ytd-expander.ytd-video-secondary-info-renderer { margin-left: 0; }
#meta ytd-expander.ytd-video-secondary-info-renderer > * { margin-left: 0; }
ytd-watch-metadata { display: none !important; }
tp-yt-paper-button#more, tp-yt-paper-button#less { outline: none !important; }
tp-yt-paper-button#more *, tp-yt-paper-button#less * { pointer-events: none !important; }
`;
    document.head.appendChild(styles);
}

waitForElement("ytd-expander #content ~ tp-yt-paper-button#more").then(function(elm){
    addSTUFF();
});