Raw Source
xanguejunior / YouTube Quick Comment

// ==UserScript==
// @name         YouTube Quick Comment
// @namespace    http://tampermonkey.net/
// @version      2025.07.04
// @description  Insert prewritten comments and hide the #full-bleed-container element on YouTube. Compact icon-only buttons with a floating menu for quick engagement actions on videos.
// @author       xanguejunior
// @match        https://www.youtube.com/watch*
// @grant        GM_addStyle
// @updateURL https://openuserjs.org/meta/xanguejunior/YouTube_Comentário_Rápido.meta.js
// @downloadURL https://openuserjs.org/install/xanguejunior/YouTube_Comentário_Rápido.user.js
// @icon         https://infoagile.com.br/_favicons_legais/moving_e.ico
// @copyright 2025, xanguejunior (https://openuserjs.org/users/xanguejunior)
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const comments = [
        "Dropping a comment to support!",
        "Thanks for the video!",
        "Bumping this up...",
        "Ty :D",
        "Nice one!",
        "Great content!",
        "Really good work!"
    ];

    const idMenu = 'quickCommentMenu';
    const idCommentBtn = 'toggleCommentMenuBtn';
    const idHideBtn = 'toggleContainerBtn';

    GM_addStyle(`
        #${idMenu} {
            position: fixed;
            top: 130px;
            right: 20px;
            z-index: 9999;
            background: #ffffffee;
            border: 1px solid #ccc;
            padding: 10px;
            border-radius: 12px;
            box-shadow: 0 0 10px rgba(0,0,0,0.2);
            font-family: Arial, sans-serif;
        }

        #${idMenu} button {
            display: block;
            width: 100%;
            margin: 4px 0;
            padding: 6px 10px;
            font-size: 14px;
            border: none;
            background-color: #f1f1f1;
            border-radius: 6px;
            cursor: pointer;
        }

        #${idMenu} button:hover {
            background-color: #e0e0e0;
        }

        #${idCommentBtn},
        #${idHideBtn} {
            position: fixed;
            top: 80px;
            z-index: 9999;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: #007bff;
            color: white;
            border: none;
            font-size: 18px;
            cursor: pointer;
        }

        #${idCommentBtn} { right: 20px; }
        #${idHideBtn} { right: 70px; }

        #${idCommentBtn}:hover,
        #${idHideBtn}:hover {
            background: #0056b3;
        }
    `);

    const commentBtn = document.createElement('button');
    commentBtn.id = idCommentBtn;
    commentBtn.innerText = '💬';
    document.body.appendChild(commentBtn);

    const hideBtn = document.createElement('button');
    hideBtn.id = idHideBtn;
    hideBtn.innerText = '🛑';
    document.body.appendChild(hideBtn);

    const menu = document.createElement('div');
    menu.id = idMenu;
    menu.style.display = 'none';
    document.body.appendChild(menu);

    comments.forEach(text => {
        const btn = document.createElement('button');
        btn.textContent = text;
        btn.addEventListener('click', () => insertComment(text));
        menu.appendChild(btn);
    });

    commentBtn.addEventListener('click', () => {
        menu.style.display = menu.style.display === 'none' ? 'block' : 'none';
    });

    let containerHidden = false;
    hideBtn.addEventListener('click', () => {
        const target = document.getElementById('full-bleed-container');
        if (target) {
            target.style.display = containerHidden ? '' : 'none';
            containerHidden = !containerHidden;
            hideBtn.innerText = containerHidden ? '✅' : '🛑';
        } else {
            alert('Element #full-bleed-container not found.');
        }
    });

    function insertComment(text) {
        const field = document.querySelector("#contenteditable-root[contenteditable='true']");
        if (field) {
            field.focus();
            document.execCommand('insertText', false, text);
        } else {
            alert("Comment field not found. Scroll to the comment section.");
        }
    }

})();