YouTube Comment & Watch History Button

Adds buttons to access YouTube comment and watch history, even when logged out.

اعتبارا من 03-04-2025. شاهد أحدث إصدار.

// ==UserScript==
// @name         YouTube Comment & Watch History Button
// @namespace    https://greasyfork.org/en/scripts/
// @version      1.0
// @description  Adds buttons to access YouTube comment and watch history, even when logged out.
// @author       YourName
// @match        *://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addButtons() {
        let header = document.querySelector("#buttons");
        if (!header || document.querySelector("#history-button")) return;

        // Create history button
        let historyBtn = document.createElement("button");
        historyBtn.id = "history-button";
        historyBtn.textContent = "📜 History";
        historyBtn.style.marginRight = "10px";
        historyBtn.onclick = function() {
            window.open("https://www.youtube.com/feed/history", "_blank");
        };

        // Create comments button
        let commentsBtn = document.createElement("button");
        commentsBtn.id = "comments-button";
        commentsBtn.textContent = "💬 Comments";
        commentsBtn.onclick = function() {
            window.open("https://www.youtube.com/feed/comments", "_blank");
        };

        // Style buttons
        [historyBtn, commentsBtn].forEach(btn => {
            btn.style.padding = "5px 10px";
            btn.style.fontSize = "14px";
            btn.style.cursor = "pointer";
            btn.style.border = "1px solid #ccc";
            btn.style.borderRadius = "5px";
            btn.style.background = "#f8f8f8";
        });

        // Add buttons to header
        header.prepend(commentsBtn);
        header.prepend(historyBtn);
    }

    // Observe page changes and add buttons
    let observer = new MutationObserver(addButtons);
    observer.observe(document.body, { childList: true, subtree: true });
})();