🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/06 12:54:50
🔄 下次更新时间:2026/01/06 13:54:50
手动刷新缓存

Youtube download button - y2meta

This Script Adds a Download Button on the right side of the subscribe button, you can easily download Audio/Video

Verze ze dne 07. 11. 2025. Zobrazit nejnovější verzi.

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 download button - y2meta
// @namespace       http://tampermonkey.net/
// @version         3.3
// @author          God Mario
// @match           *://*.youtube.com/*
// @match           *://*id.y2meta.tube/*
// @run-at          document-start
// @icon            https://cdn.icon-icons.com/icons2/822/PNG/512/download_icon-icons.com_66472.png
// @grant           GM_addStyle
// @grant           GM_setValue
// @grant           GM_getValue
// @connect         *://*id.y2meta.com/*
// @license         MIT
// @description     This Script Adds a Download Button on the right side of the subscribe button, you can easily download Audio/Video
// ==/UserScript==

(function () {
    'use strict';

    if (window.location.hostname === 'www.youtube.com' && window.location.pathname === '/watch') {

        const SELECTORS = {
            subscribeButton: '#subscribe-button button',
            downloadButton: '.y2mate-download-btn'
        };

        const STRINGS = {
            downloadText: 'Download'
        };

        const STYLES = `
        .y2mate-download-btn {
            background-color: var(--yt-spec-additive-background);
            color: var(--yt-spec-text-primary);
            margin: 0px 2px;
            border-radius: 18px;
            width: 100px;
            height: 36px;
            line-height: 36px;
            text-align: center;
            font-style: normal;
            font-size: 14px;
            font-family: Roboto, Noto, sans-serif;
            font-weight: 500;
            text-decoration: none;
            display: flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
            border: none;
            cursor: pointer;
        }
        .y2mate-download-btn:hover {
            background-color: var(--yt-spec-mono-tonal-hover);
            color: var(--yt-spec-text-primary);
        }
        .y2mate-buttons-wrapper {
            display: flex;
            align-items: center;
            gap: 6px;
        }
    `;

        GM_addStyle(STYLES);

        function createDownloadButton() {
            if (document.querySelector(SELECTORS.downloadButton)) {
                return null;
            }

            const downloadButton = document.createElement('button');
            downloadButton.className = 'y2mate-download-btn';
            downloadButton.textContent = `${STRINGS.downloadText}`;

            downloadButton.addEventListener('click', function () {
                const videoUrl = window.location.href;
                GM_setValue('ultimaUrlYoutube', videoUrl);
                const downloadDomains = ['id.y2meta.tube/'];
                const newUrl = videoUrl.replace('www.youtube.com/', downloadDomains);
                window.open(newUrl, '_blank');
            });

            return downloadButton;
        }

        function addDownloadButton() {
            const subscribeButton = document.querySelector(SELECTORS.subscribeButton);
            if (!subscribeButton) {
                return;
            }

            const downloadButton = createDownloadButton();
            if (!downloadButton) {
                return;
            }

            const container = subscribeButton.closest('#subscribe-button');
            if (container) {
                const wrapper = document.createElement('div');
                wrapper.className = 'y2mate-buttons-wrapper';

                container.parentNode.insertBefore(wrapper, container);
                wrapper.appendChild(container);
                wrapper.appendChild(downloadButton);
            }
        }

        function init() {
            if (window.location.pathname.includes('/watch')) {
                addDownloadButton();
            }
        }

        const observer = new MutationObserver(init);

        observer.observe(document.documentElement, {
            childList: true,
            subtree: true
        });

        window.addEventListener('yt-navigate-finish', init);

        init();

    } else if (window.location.hostname === 'id.y2meta.tube') {


        function pegarUrlEnInput() {

            const urlGuardada = GM_getValue('ultimaUrlYoutube', null);


            if (urlGuardada) {

                const campoInput = document.querySelector('#txt-url');
                const botonSubmit = document.querySelector('#btn-submit');

                if (campoInput && botonSubmit) {
                    campoInput.value = urlGuardada;
                    console.log('✅ URL de YouTube pegada en el input:', urlGuardada);

                    campoInput.dispatchEvent(new Event('input', { bubbles: true }));

                    botonSubmit.click();
                    console.log('✅ Botón #btn-submit clickeado automáticamente.');

                    GM_setValue('ultimaUrlYoutube', '');

                } else {
                    console.warn('⚠️ Elemento(s) no encontrado(s). Reintentando...');

                    setTimeout(pegarUrlEnInput, 200);
                }
            } else {
                console.log('No se encontró una URL de YouTube guardada.');
            }
        }

        window.addEventListener('load', pegarUrlEnInput);

    }
}
)();