Youtube download button - yt1s.com (revised SuchtiOnTour Edit)

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

目前为 2024-08-08 提交的版本。查看 最新版本

// ==UserScript==
// @name            Youtube download button - yt1s.com (revised SuchtiOnTour Edit)
// @name:de         Youtube download button - yt1s.com (revised SuchtiOnTour Edit)
// @namespace       Violentmonkey Scripts
// @match           https://www.youtube.com/watch
// @match           https://*.youtube.com/*
// @grant           GM_addStyle
// @run-at          document-idle
// @version         1.2.0
// @author          SuchtiOnTour
// @license         MIT
// @description     This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:pt-BR This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ar This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:bg This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:cs This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:da This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:de This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:el This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:eo This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:es This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:fi This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:fr This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:fr-CA This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:he This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:hu This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:id This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:it This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ja This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ko This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:nb This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:nl This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:pl This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ro This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ru This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:sk This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:sr This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:sv This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:th This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:tr This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:uk This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:ug This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:vi This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:zh-CN This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// @description:zh-TW This Script Adds a Download Button on the left side of the subscribe button, you can easily download Audio/Video
// ==/UserScript==

(function() {
    const API = "https://yt1s.com/en/youtube-to-mp3?q=";
    const BUTTON_ID = "dwnldBtn";
    const TARGET_BUTTON = "#subscribe-button"; // Updated target element selector

    const buttonStyle = `
        #${BUTTON_ID} {
            background-color: #0F0F0F;
            color: #FFFFFF;
            border: 1px solid #3F3F3F;
            border-color: rgba(255,255,255,0.2);
            margin-right: 8px;
            padding: 0 16px;
            border-radius: 18px; /* Updated border radius */
            font-size: 14px;
            font-family: Roboto, Noto, sans-serif;
            font-weight: 500;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            height: 36px;
            line-height: normal;
        }
        #${BUTTON_ID}:hover {
            background-color: #3F3F3F;
            color: #ffffff;
            border-color: #3F3F3F;
        }
    `;

    GM_addStyle(buttonStyle);

    function waitForElement(selector) {
        return new Promise(resolve => {
            if (document.querySelector(selector)) {
                return resolve(document.querySelector(selector));
            }
            const observer = new MutationObserver(mutations => {
                if (document.querySelector(selector)) {
                    resolve(document.querySelector(selector));
                    observer.disconnect();
                }
            });
            observer.observe(document.body, { childList: true, subtree: true });
        });
    }

    function addButton() {
        waitForElement(TARGET_BUTTON).then((btn) => {
            if (!btn) {
                console.error('Target button not found');
                return;
            }

            const downloadButton = document.createElement('a');
            downloadButton.href = `${API + encodeURIComponent(window.location.href)}`;
            downloadButton.target = '_blank';
            downloadButton.id = BUTTON_ID;
            downloadButton.innerText = 'Download';
            btn.parentNode.insertBefore(downloadButton, btn);
        }).catch(error => {
            console.error(`Error adding button: ${error}`);
        });
    }

    function updateButton() {
        waitForElement(`#${BUTTON_ID}`).then((btn) => {
            if (!btn) {
                console.error('Download button not found');
                return;
            }
            btn.href = API + encodeURIComponent(window.location.href);
        }).catch(error => {
            console.error(`Error updating button: ${error}`);
        });
    }

    window.onload = addButton;
    window.addEventListener("yt-navigate-start", () => {
        setTimeout(addButton, 1000);
    }, true);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址