YouTube Simple Downloader

Download videos and audio from YouTube using simple buttons in the extension menu

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         YouTube Simple Downloader
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Download videos and audio from YouTube using simple buttons in the extension menu
// @author       Magneto1
// @license      MIT
// @match        https://*.youtube.com/*
// @grant        GM_registerMenuCommand
// @grant        GM_openInTab
// ==/UserScript==

(function() {
    'use strict';

    // Funzione per estrarre l'ID del video da YouTube
    function extractYT(url) {
        const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
        const match = String(url).match(regExp);
        return (match && match[7].length === 11) ? match[7] : false;
    }

    // Funzione per il download del video in formato MP4
    function downloadVideo() {
        const videoId = extractYT(window.location.href);
        if (videoId) {
            const downloadUrl = `https://tubemp3.to/en/download/${videoId}/mp4`; // Modifica l'URL in base al servizio di download
            GM_openInTab(downloadUrl, { active: true });
        } else {
            alert("Nessun video trovato.");
        }
    }

    // Funzione per il download dell'audio in formato MP3
    function downloadAudio() {
        const videoId = extractYT(window.location.href);
        if (videoId) {
            const downloadUrl = `https://tubemp3.to/en/download/${videoId}/mp3`; // Modifica l'URL in base al servizio di download
            GM_openInTab(downloadUrl, { active: true });
        } else {
            alert("Nessun video trovato.");
        }
    }

    // Aggiungi i comandi al menu dell'estensione
    GM_registerMenuCommand("Download YouTube Video (MP4)", downloadVideo);
    GM_registerMenuCommand("Download YouTube Audio (MP3)", downloadAudio);
})();