YouTube MP3 Button (Simple & Working)

Simple MP3 download button (redirect-based, works)

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         YouTube MP3 Button (Simple & Working)
// @namespace    simple-mp3
// @version      1.0
// @description  Simple MP3 download button (redirect-based, works)
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function addButton() {
        if (!location.pathname.startsWith('/watch')) return;
        if (document.querySelector('#simple-mp3-btn')) return;

        const target = document.querySelector('ytd-subscribe-button-renderer');
        if (!target) return;

        const btn = document.createElement('button');
        btn.id = 'simple-mp3-btn';
        btn.textContent = 'MP3';
        btn.style.cssText = `
            margin-left:8px;
            padding:6px 12px;
            background:#ff0000;
            color:#fff;
            border:none;
            border-radius:2px;
            cursor:pointer;
            font-size:12px;
        `;

        btn.onclick = () => {
            const url = encodeURIComponent(location.href);

            // любой рабочий онлайн-конвертер
            window.open(
                `https://y2mate.is/youtube-mp3/${url}`,
                '_blank'
            );
        };

        target.after(btn);
    }

    new MutationObserver(addButton)
        .observe(document.body, { childList: true, subtree: true });
})();