YouTube™ Multi Downloader v9.0 🌐🚀💯 - TubeMP3.to (NO ADS & NEW LAYOUT FOR YT! 🚫🤩)

This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!

As of 04.09.2024. See ბოლო ვერსია.

// ==UserScript==
// @name YouTube™ Multi Downloader v9.0 🌐🚀💯 - TubeMP3.to (NO ADS & NEW LAYOUT FOR YT! 🚫🤩)
// @name:pt-BR YouTube™ Multi Downloader v9.0 🌐🚀💯 - TubeMP3.to (SEM ANÚNCIOS & NOVO LAYOUT PARA YT! 🚫🤩)
// @description This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:pt-BR Esse script adiciona um botão de download, uma maneira mais rápida de baixar áudio e vídeo do YouTube e com qualidade garantida. Este site é muito simples, rápido e eficaz para baixar! Melhor de todos!
// @description:ar This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:bg This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:cs This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:da This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:de This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:el This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:eo This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:es This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:fi This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:fr This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:fr-CA This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:he This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:hu This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:id This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:it This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:ja This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:ko This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:nb This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:nl This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:pl This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:ro This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:ru This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:sk This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:sr This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:sv This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:th This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:tr This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:uk This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:ug This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:vi This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:zh-CN This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @description:zh-TW This script adds a download button, a faster way to download audio and video from YouTube with guaranteed quality. This site is very simple, fast and effective to download! Best of all!
// @namespace https://greatest.deepsurf.us/users/152924
// @homepageURL https://greatest.deepsurf.us/scripts/34613
// @supportURL https://greatest.deepsurf.us/scripts/34613/feedback
// @author Punisher
// @version 9.0
// @date 2024-09-03
// @icon https://i.imgur.com/InuDDVK.png
// @compatible chrome
// @compatible firefox
// @compatible opera
// @compatible safari
// @compatible edge
// @license CC-BY-NC-ND-4.0
// @match https://*.youtube.com/*
// @grant GM_addStyle
// @run-at document-idle
// ==/UserScript==

(function() {
    const punisherYT = "https://tubemp3.to/";
    const tubeID = "dwnldBtn";
    const currentButton = "#owner";
    const addClick = `
        #${tubeID} {
            background-color: #F1F1F1;
            color: #FF0000;
            border: 1px solid;
            border-color: rgba(255,255,255,0.2);
            margin-left: 8px;
            padding: 0 16px;
            border-radius: 18px;
            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;
        }
        #${tubeID}:hover {
            background-color: #D9D9D9;
            color: #FF0000;
            border-color: #F1F1F1;
        }
    `;
    GM_addStyle(addClick);

    function inspectPg(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() {
        inspectPg(currentButton).then((btnContainer) => {
            if (!btnContainer) {
                return;
            }
            if (document.querySelector(`#${tubeID}`)) {
            } else {
                const downloadBtn = document.createElement('a');
                downloadBtn.href = `${punisherYT + decodeURIComponent(window.location.href)}`;
                downloadBtn.target = '_blank';
                downloadBtn.id = tubeID;
                downloadBtn.innerText = 'Download';
                btnContainer.appendChild(downloadBtn);
            }
        });
    }

    function pageLoad() {
        inspectPg(`#${tubeID}`).then((btn) => {
            if (!btn) {
                return;
            }
            btn.href = punisherYT + decodeURIComponent(window.location.href);
        });
    }

    let buttonSet = false;
    function checkButton() {
        if (window.location.pathname === '/watch' && !buttonSet) {
            addButton();
            buttonSet = true;
            setTimeout(pageLoad, 2000);
        }
    }
    window.addEventListener("yt-navigate-finish", () => {
        buttonSet = false;
        checkButton();
    });
    checkButton();
})();