YouTube zu MP4 Stackoverflow

var links = new String();
var downlink = new String();
var has22 = new Boolean();
has22 = false;
var Marked = false;

var FMT_DATA = fmt_url_map;//This is html text that you have to grab. In case of extension it was readily available through:document.getElementsByTagName('script');

var StrSplitter1 = '%2C', StrSplitter2 = '%26', StrSplitter3 = '%3D';
if (FMT_DATA.indexOf(',') > -1) { //Found ,
    StrSplitter1 = ',';
    StrSplitter2 = (FMT_DATA.indexOf('&') > -1) ? '&' : '\\u0026';
    StrSplitter3 = '=';
}

var videoURL = new Array();
var FMT_DATA_PACKET = new Array();
var FMT_DATA_PACKET = FMT_DATA.split(StrSplitter1);

for (var i = 0; i < FMT_DATA_PACKET.length; i++) {
    var FMT_DATA_FRAME = FMT_DATA_PACKET[i].split(StrSplitter2);
    var FMT_DATA_DUEO = new Array();

    for (var j = 0; j < FMT_DATA_FRAME.length; j++) {
        var pair = FMT_DATA_FRAME[j].split(StrSplitter3);
        if (pair.length == 2) {
            FMT_DATA_DUEO[pair[0]] = pair[1];
        }
    }

    var url = (FMT_DATA_DUEO['url']) ? FMT_DATA_DUEO['url'] : null;

    if (url == null) continue;
    url = unescape(unescape(url)).replace(/\\\//g, '/').replace(/\\u0026/g, '&');
    var itag = (FMT_DATA_DUEO['itag']) ? FMT_DATA_DUEO['itag'] : null;
    var itag = (FMT_DATA_DUEO['itag']) ? FMT_DATA_DUEO['itag'] : null;
    if (itag == null) continue;
    var signature = (FMT_DATA_DUEO['sig']) ? FMT_DATA_DUEO['sig'] : null;
    if (signature != null) {
        url = url + "&signature=" + signature;
    }
    if (url.toLowerCase().indexOf('http') == 0) { // validate URL 

        if (itag == '5') {
            links += '<a href="' + url + '&title=' + username + title + quality240 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v240p">FLV (240p)</span></a>';
        }
        if (itag == '18') {
            links += '<a href="' + url + '&title=' + username + title + quality360 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v360p">MP4 (360p)</span></a>';
        }
        if (itag == '35') {
            links += '<a href="' + url + '&title=' + username + title + quality480 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v480p">FLV (480p)</span></a>';
        }
        if (itag == '22') {
            links += '<a href="' + url + '&title=' + username + title + quality720 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v720p">MP4 HD (720p)</span></a>';
        }
        if (itag == '37') {
            links += ' <a href="' + url + '&title=' + username + title + quality1080 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v1080p">MP4 HD (1080p)</span></a>';
        }
        if (itag == '38') {
            links += '<a href="' + url + '&title=' + username + title + quality4k + '"style="text-decoration:none"><span class="yt-uix-button-menu-item"  id="v4k">MP4 HD (4K)</span></a>';
        }

        FavVideo();
        videoURL[itag] = url;
        console.log(itag);
    }
}
Better Butterfly