YouTube MP3 Button (Simple & Working)

Simple MP3 download button (redirect-based, works)

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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 });
})();