Youtube Comments Section First

Title description and comments section first, suggestions on the right

Versione datata 11/04/2024. Vedi la nuova versione l'ultima versione.

// ==UserScript==
// @name         Youtube Comments Section First
// @name:zh-CN   Youtube 详情评论在左边
// @namespace    http://tampermonkey.net/
// @version      2024-04-12
// @description  Title description and comments section first, suggestions on the right
// @description:zh-CN   标题、描述和评论会在左侧占据更多空间,视频建议则在右侧显示。
// @author       leovoon
// @match        *.youtube.com/watch*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      GNU GPLv3

// ==/UserScript==

(function() {
    'use strict';

     // Function to be called when the target element exists
    function waitForElement(selector, callback) {
        const targetNode = document.querySelector(selector);
        if (targetNode) {
            callback(targetNode);
            return;
        }

        const observer = new MutationObserver(mutationsList => {
            for (const mutation of mutationsList) {
                if (mutation.type === 'childList') {
                    const targetNode = document.querySelector(selector);
                    if (targetNode) {
                        callback(targetNode);
                        observer.disconnect();
                        break;
                    }
                }
            }
        });

        // Start observing the target node for changes in children
        observer.observe(document.body, { childList: true, subtree: true });
    }

    waitForElement('#columns', function(targetNode) {
        if(!targetNode) return

        targetNode.children[0].style.flexGrow = 1
         targetNode.children[0].style.flexBasis = 0
        targetNode.children[0].style.minWidth = 'auto'
         targetNode.children[0].style.order = 2

        targetNode.children[1].style.flexGrow = 5
        targetNode.children[1].style.flexBasis = 0
        targetNode.children[1].style.order = 1


    });




})();