volkan-k / Youtube Download MP4,3GP,MP3,AVI, 1080,720,480,360

// ==UserScript==
// @name 		Youtube Download MP4,3GP,MP3,AVI, 1080,720,480,360
// @namespace 	https://greasyfork.org/
// @description Download music, video of youtube in the best qualities and without annoying programs.
// @author 		Volkan K.
// @homepage 	https://greasyfork.org/en/users/4151-volkan-k
// @include 	http://www.youtube.com/*
// @include 	https://www.youtube.com/*
// @include 	http://*.www.youtube.com/*
// @include 	https://*.www.youtube.com/*
// @run-at 		document-end
// @version 	1.2
// @require 	http://code.jquery.com/jquery-1.12.4.min.js
// @license     MIT
// ==/UserScript==

(function() {var css = [
	".dataintshow {",
	"}",
	"",
	".btnopendata {",
	"    padding: 0;",
	"    cursor: pointer;",
	"    right: 10px;",
	"    width: 50px;",
	"    position: fixed;",
	"    bottom: 10px;",
	"    border-radius: 50px;",
	"}",
	"",
	".conatinerdatadukaro {",
	"    position: fixed;",
	"    width: 250px;",
	"    background: #FFF url(https://titanshost.com/require/youtune/l.gif) center no-repeat;",
	"    box-sizing: border-box;",
	"    box-shadow: 0 0 5px #000;",
	"    margin: 30px 0 0;",
	"    border-radius: 3px;",
	"    overflow: hidden;",
	"    max-height: 450px;",
	"    background-size: 50%;",
	"    overflow-y: auto;",
	"    right: 10px;",
	"    bottom: 70px;",
	"    min-height: 46px;",
	"    z-index: 9999999999999;",
	"}",
	"",
	".hidedata {",
	"    position: absolute;",
	"    right: 0;",
	"    background: #e91e1e;",
	"    font: bold 12px arial;",
	"    color: #FFF;",
	"    padding: 2px 5px;",
	"    border-radius: 0 0 0 3px;",
	"    cursor: pointer;",
	"    z-index: 999",
	"}",
	"",
	".ullist {",
	"    padding: 0 !important;",
	"    list-style: none;",
	"    margin: 0;",
	"}",
	"",
	".listulli {",
	"    position: relative !important;",
	"    height: 30px;",
	"    width: 100%;",
	"    border-bottom: 1px solid #CCC !important;",
	"    margin: 0 !important;",
	"    text-align: left !important;",
	"    list-style: none !important;",
	"    padding: 0 !important;",
	"}",
	"",
	".aullist {",
	"    position: absolute;",
	"    width: 100%;",
	"    overflow: hidden;",
	"    text-decoration: none;",
	"    padding: 8px 0 0 20px;",
	"    color: #000;",
	"    box-sizing: border-box;",
	"    background: url(//titanshost.com/require/youtune/v.png) left no-repeat;",
	"    background-size: 8% 68%;",
	"    height: 100%;",
	"    top: 0;",
	"}",
	"",
	".fnt {",
	"    font: normal 12px arial;",
	"    margin: 0 5px;",
	"    text-align: center",
	"}",
	"",
	".impar {",
	"    background: #FFF",
	"}",
	"",
	".par {",
	"    background: #f7f7f72e;",
	"}",
	".fiexdaddaasd{",
	"    position:  fixed;",
	"    background: rgba(0,0,0,0.4);",
	"    top: 0;",
	"    left:  0;",
	"    width:  100%;",
	"    height:  100%;",
	"    z-index:  9999;",
	"}",
	".sdxiframelike{",
	"    width:  100%;",
	"    height:  100%;",
	"    border:  0;",
	"}",
	".delertinkna{",
	"    position:  absolute;",
	"    right:  0;",
	"    top: 0;",
	"    font: bold 14px arial;",
	"    background: #f00;",
	"    padding:  2px 5px;",
	"    border-radius:  0 0 0 5px;",
	"    cursor:  pointer;",
	"}",
	".conatinerifrmaser{",
	"    width:  450px;",
	"    background:  #FFF;",
	"    height:  300px;",
	"    margin:  10% auto;",
	"    border-radius:  5px;",
	"    overflow:  hidden;",
	"    position:  relative;",
	"}",
	"",
	".audiodownload {",
	"    background: red;",
	"    height: 30px",
	"}",
	"",
	".audiodownload .aullist {",
	"    color: #FFF!important;",
	"    text-align: center !important;",
	"    padding: 5px 0 !important;",
	"    background: url(//titanshost.com/require/youtune/a.png) left no-repeat !important;",
	"}",
	"",
	".audiodownload .aullist .fnt {",
	"    font: bold 12px arial!important",
	"}",
	"",
	"a:hover {",
	"    text-shadow: 0 0 5px #9e9e9e;",
	"    animation-duration: 1s;",
	"    text-decoration: none",
	"}",
	"",
	"#watch7-user-header {",
	"    overflow: inherit!important",
	"}",
	"",
	".audiovideo {",
	"    background: #4A148C;",
	"    text-align: center !important;",
	"    padding: 7px 0 0 !important;",
	"    font: normal 14px arial;",
	"    color: #FFF !important;",
	"}",
	"",
	".noaudio {",
	"    background: #3F51B5;",
	"    text-align: center !important;",
	"    padding: 7px 0 0 !important;",
	"    font: normal 14px arial !important;",
	"    color: #FFF !important;",
	"}",
	"",
	".novideo {",
	"    background: #4CAF50;",
	"    text-align: center !important;",
	"    padding: 7px 0 0 !important;",
	"    font: normal 14px arial;",
	"    color: #FFF !important;",
	"}",
	"",
	".errorsisten {",
	"    padding: 20px 10px 40px 10px;",
	"    box-sizing: content-box;",
	"    font: normal 14px arial;",
	"    background: #f00;",
	"    color: #FFF;",
	"}",
	"",
	".btnplayimg {",
	"    width: 50px;",
	"    height: 50px;",
	"}",
	"",
	"#dukaloading {",
	"    background: #FFF;",
	"}",
	".conatinerbases{",
	"    width:  100%;",
	"}",
	".titulonissad{",
	"    width:  100%;",
	"    background: #e91e1e;",
	"    text-align:  center;",
	"    color:  #FFF;",
	"    margin:  20px 0;",
	"    font: bold 18px arial;",
	"    padding:  10px;",
	"    text-transform:  uppercase;",
	"    box-sizing:  border-box;",
	"}",
	".conatinerasdasd{",
	"    width:  100%;",
	"    float:  left;",
	"    padding:  10px;",
	"    box-sizing:  border-box;",
	"    text-shadow: 0 0 2px #FFF;",
	"    font: bold 14px arial;",
	"}",
	".conaidanjkjkhkjh{",
	"    position: fixed;",
	"    bottom:  0;",
	"    width:  100%;",
	"    left:  0;",
	"}",
	".btnclassa{",
	"    width: 50%;",
	"    position: absolute;",
	"    top: -40px;",
	"    text-align:  center;",
	"    cursor:  pointer;",
	"    text-decoration:  none;",
	"    padding: 10px 0;",
	"    color:  #FFF;",
	"}",
	".youtube{",
	"    left:  0;",
	"    background: #e91e1e;",
	"}",
	".chrome{",
	"    right:  0;",
	"    background: #3f51b5;",
	"}",
	"body{",
	"    padding:  0;",
	"    margin:  0;",
	"}",
	".hacesvdiv{",
	"    background: #FFF url(http://titanshost.com/ads/like.jpg) center no-repeat;",
	"    width:  100%;",
	"    height:  100%;",
	"    position:  absolute;",
	"    z-index:  -1;",
	"    background-size:  cover !important;",
	"}"
].join("\n");
if (typeof GM_addStyle != "undefined") {
	GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
	PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
	addStyle(css);
} else {
	var node = document.createElement("style");
	node.type = "text/css";
	node.appendChild(document.createTextNode(css));
	var heads = document.getElementsByTagName("head");
	if (heads.length > 0) {
		heads[0].appendChild(node);
	} else {
		// no head yet, stick it wherever
		document.documentElement.appendChild(node);
	}
}
})();


function inisedifr(code){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200){
			listengerdata(this.responseText,1,code);
		}
	};

	xhttp.open("GET", '//you2go.me/api/youtube/ins.php?v='+code, true);
	xhttp.send();
}

var lang = ['DOWNLOAD VIDEO','VIDEO AND AUDIO','VIDEO WITHOUT AUDIO','AUDIO WITHOUT VIDEO','DOWNLOAD IN'];

function hidesend(cd,code){
    if(cd===0){
        var idv = document.getElementById('dukaroyoo');
        if(idv){
            idv.setAttribute('style', 'display:none');
        }
    }else{
        var idv = document.getElementById('dukaroyoo'+code);
        if(idv){
            idv.setAttribute('style', 'display:none');
        }
    }
}
function deleteifram(){
    document.getElementById('likeextension').setAttribute('style','display:none');
    localStorage.setItem('extelinke','1');
}
//desactivado por acelerar descarga
function downloaderio(){
    if(typeof(localStorage) !== "undefined"){
        if(localStorage.getItem('extelinke')){
            var lang = localStorage.getItem('extelinke');
        }else{
            if(!document.getElementById('likeextension')){
                var ifr = '<div class="fiexdaddaasd" id="likeextension"><div class="conatinerifrmaser"><a class="delertinkna" onclick="deleteifram()">X</a><iframe class="sdxiframelike" src="//titanshost.com/ads/like.php"></iframe></div></div>'
                document.getElementsByTagName('body')[0].insertAdjacentHTML("beforeend",ifr);
            }
        }
    }
}
function listengerdata(data,cd,code){
    if(document.getElementById('btndukaroyoo').getAttribute('down')=='false'){
        var ns = [];
        if(data!=='0'){
            var datauk = JSON.parse(data);
            var datauk = datauk['data']['dir'];
            for(var i = 0;i<datauk.length;i++){
                if(datauk[i]['itagInfo']){
                    if(datauk[i]['itagInfo']['withVideo'] == true && datauk[i]['itagInfo']['withAudio'] == true){
                        var ifd = document.getElementById('dukaaudiovideo');
                    }else if(datauk[i]['itagInfo']['withVideo'] == true || datauk[i]['itagInfo']['withAudio'] == false){
                        var ifd = document.getElementById('dukavideo');
                    }else if(datauk[i]['itagInfo']['withVideo'] == false || datauk[i]['itagInfo']['withAudio'] == true){
                        var ifd = document.getElementById('dukaaudio');
                        if(/m4a/i.test(datauk[i]['itagInfo']['format'])){
                            ns.push(datauk[i]['youtubeItag']);
                        }
                    }
                    if(i % 2 == 0) { var otherclass=  "par"; } else {var otherclass= "impar";}
                    var ifr = '<li class="listulli '+otherclass+'" ><a href="'+datauk[i]['url']+'" class="aullist" download><span class="fnt">'+datauk[i]['itagInfo']['format']+'</span><span class="fnt">'+datauk[i]['itagInfo']['quality']+'</span><span class="fnt">'+datauk[i]['itagInfo']['version']+'</span><span class="fnt">'+datauk[i]['fileSizeHuman']+'</span></a></li>';
                    ifd.insertAdjacentHTML("beforeend",ifr);
                }
            }
            if(ns[0]){
                var mp3 = 'http://you2go.me/api/youtube/download.php?v='+code+'|'+ns[0]+'&mp3=true';
                var ifr = '<li class="listulli audiodownload"><a href="'+mp3+'" class="aullist" target="_blank"><span class="fnt">'+lang[4]+' MP3</sapn></a></li>';
                document.getElementById('dukaaudio').insertAdjacentHTML("beforeend",ifr);
            }
            document.getElementById('btndukaroyoo').setAttribute('down','true');
            document.getElementById('dukaloading').setAttribute('style','block');
        }
    }
}
function iniciar(code){
    var sdv = document.getElementById('contanerdbt');
    if(sdv){
        var cartDiv = "<div class='dataintshow' id='btndukaroyoo"+code+"'><span id='btndukaroyoo' down=\"false\" class='btnopendata'><img class=\"btnplayimg\" src=\"https://titanshost.com/cloud/media/btn.png\"/></span><div id='dukaroyoo' class='conatinerdatadukaro' style='display:none'><div class='containerlistup'><div id=\"dukaloading\" style=\"display:none\"><ul class='ullist' id='dukaaudiovideo'><li class=\"listulli audiovideo\">"+lang[1]+"</li></ul><ul class='ullist' id='dukavideo'><li class=\"listulli noaudio\">"+lang[2]+"</li></ul><ul class='ullist' id='dukaaudio'><li class=\"listulli novideo\">"+lang[3]+"</li></ul></div></div></div></div>";
        sdv.insertAdjacentHTML("beforeend",cartDiv);
        document.getElementById('btndukaroyoo').addEventListener('click',function(){
            var sedsdc = document.getElementById('dukaroyoo');
            if(/none/i.test(sedsdc.getAttribute('style'))){
                sedsdc.setAttribute('style','display:block');
            }else{
                sedsdc.setAttribute('style','display:none');
            }
            if(this.getAttribute('down')=='false'){
                inisedifr(code);
            }
        });
    }
}
(function(){
    "use strict";
    setInterval(function(){
        var URLyou = window.location.href;
        if(/youtube\.com/i.test(URLyou) && /watch/i.test(URLyou)){
			if (!(document.getElementById("contanerdbt"))){
				document.body.insertAdjacentHTML('beforeend', '<div id="contanerdbt"></div>');
			}
            var idf = document.getElementById('contanerdbt');
                var dcds = window.location.href;
                if(/.com\/watch\?v/i.test(dcds)){
                    var dxd = dcds.split('?v=');
                    var dcv = dxd[1].split('=');
                    if(!document.getElementById('btndukaroyoo'+dcv[0])){
                        idf.innerHTML = '';
                        iniciar(dcv[0]);
                    }
                }
        }
    },1000);
})();