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.

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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