YouTube™ Multi Downloader v9.2 🌐🚀💯 - YT1s.com (SEM ANÚNCIOS & NOVO LAYOUT PARA YT! 🚫🤩)

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!

// ==UserScript==
// @name YouTube™ Multi Downloader v9.2 🌐🚀💯 - YT1s.com (NO ADS & NEW LAYOUT FOR YT! 🚫🤩)
// @name:pt-BR YouTube™ Multi Downloader v9.2 🌐🚀💯 - YT1s.com (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://greasyfork.org/users/152924
// @homepageURL https://greasyfork.org/scripts/34613
// @supportURL https://greasyfork.org/scripts/34613/feedback
// @author Punisher
// @version 9.2
// @date 2024-11-16
// @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() {
    var punisherYT = "//yt1s.com/youtube-to-mp3?q=";
    var tubeID = "dwnldBtn";
    var currentButton = "#owner";
    var addClick = `
        #${tubeID} {
            background-color: #F1F1F1;
            color: #191919;
            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: #191919;
            border-color: #F1F1F1;
        }
    `;
    GM_addStyle(addClick);

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

    function addBtn() {
        inspectPg(currentButton).then((btnContainer) => {
            if (!btnContainer) {
                return;
            }
            if (document.querySelector(`#${tubeID}`)) {
            } else {
                var downloadBtn = document.createElement('a');
                downloadBtn.href = `${punisherYT + encodeURIComponent(window.location)}`;
                downloadBtn.target = '_blank';
                downloadBtn.id = tubeID;
                downloadBtn.innerText = 'Download';
                btnContainer.appendChild(downloadBtn);
            }
        });
    }

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

    extractYT = function(url) {
        var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
        var match = String(url).match(regExp);
        return (match&&match[7].length==11)? match[7]: false;
    }

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