Youtube Multiple Downloader dev

Open third-party websites directly to get YouTube.com video and audio download links

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Youtube Multiple Downloader dev
// @name:zh-CN   youtube油管多源下载
// @namespace    http://tampermonkey.net/
// @version      20250218
// @description  Open third-party websites directly to get YouTube.com video and audio download links
// @description:zh-cn 打开多个第三方网站下载YouTube音视频
// @author       gf2024
// @license      MIT
// @match        https://www.youtube.com/*
// @match        https://vget.xyz/dl*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACqtJREFUeF7tmQtQVNcZx//n7ovlvaCILx4aBEWp+IjGSTSp1bapmDoCrVaNBsa2JtWoGdMZY8eZNMmoHWNiSWOIjm21o8Yqo2SiJlOtxleMo/hEgYY3C4gIIgi7957OuY/dexeW3QXEGWVnFi73nnPP+f++//edey4ET/mHPOX60QegzwFPOYG+FHjKDdBXBPtSoC8FnnICfSnwKA1wZnNamI2nywFhpqAXXn5pZc49b8bL374myK5/cATAKWJ7uDExc/tdb/p1pc0jcYBDOMUKEISyiRFCToQ34aeJ679o62yidF+a7jY/KEc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yW9VxzgFoSfKfRmcYUY8d4W/lgc4AriyKqkRQ/Al83dfP24txHr6XaPxQE9LaI79+sD0B16T0LfPgc8CVHsjoY+B3SH3pPQt88BT0IUu6OhzwHdofck9P0/7u5AmzxRGqIAAAAASUVORK5CYII=
// @grant		 GM_registerMenuCommand
// @grant		 GM_unregisterMenuCommand
// @grant		 GM_openInTab
// @grant        window.onurlchange
// @grant        unsafeWindow
// @run-at       document-end
// ==/UserScript==
(function () {
    'use strict';
    // this function is strict...
    let menu_command_id_v;
    let menu_command_id_a;
    let menu_command_id_none;

    function addMenu(){
        let w = 640;
        let h = window.innerHeight;
        let x = window.innerWidth/2 - w/2;
        let y = window.innerHeight/2 - h/2;

        let openWin = (d)=>{
            let url = document.location.href;
            url = url.replace('.youtube.com/', d);
            window.open(url,'ymd_w',`popup,left=${x},top=${y},width=${w},height=${h}`);
        };
        let openWinQuery = (u)=>{
            let url = document.location.href;
            url = u + '?url=' + encodeURIComponent(url);
            window.open(url,'ymd_w',`popup,left=${x},top=${y},width=${w},height=${h}`);
        };
        menu_command_id_a = GM_registerMenuCommand("addYoutube", function(e) {
            openWin('.addyoutube.com/');
        }, {id:'a',accessKey:'a',autoClose:true,title:'Open addYouTube.com to download'});

        menu_command_id_v = GM_registerMenuCommand("vGet", function(e) {
            openWinQuery('https://vget.xyz/dl');
        }, {id:'v',accessKey:'v',autoClose:true,title:'Open vget.xyz to download'});

        GM_unregisterMenuCommand(menu_command_id_none);

    }

    function isMenuUrl(){
        return /^\/watch|shorts/.test(location.pathname);
    }

    function removeMenu(){
        GM_unregisterMenuCommand(menu_command_id_a);
        GM_unregisterMenuCommand(menu_command_id_v);
    }

    function changeMenu(){
        if(isMenuUrl()){
            addMenu();
        }else{
            removeMenu();
        }

    }

    changeMenu();

    window.addEventListener('urlchange', (info) =>{
        changeMenu()
    });

    // vget页面提交表单
    function postVGetForm(){
        let vgetBegin = 'https://vget.xyz/dl?url=http';
        let matchUrl = location.href.indexOf(vgetBegin);
        if(matchUrl==0){
            let ytUrl = decodeURIComponent(location.search.substring('?url='.length));
            let form = document.forms[0];
            form.url.value = ytUrl;
            form.submit();
        }
    }

    postVGetForm();
}());