Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name YouTube downloader
- // @namespace http://concentratedentropy.wordpress.com/
- // @description Download videos
- // @include http://*.youtube.com/watch?v=*
- // ==/UserScript==
- var s,h='',j=0;
- if(document.getElementById('movie_player'))
- {//not html5 mode
- var f=document.getElementById('movie_player').getAttribute('flashvars');
- var i=f.indexOf('&fmt_url_map=')+13;
- s=unescape(f.substring(i,f.indexOf('&',i))).split(/,|\|/);
- }
- else
- {
- var v=unsafeWindow.videoPlayer.toSource();
- var i=v.indexOf('html5_fmt_map:#')+17;
- var x=eval(v.substring(i,1+v.indexOf(']',i)));//>eval
- x.map(function(o){h+='<li style="display:inline;margin-right:0.5em"><a href="'+o.url+'">'+o.itag+'</a></li>';});
- i=v.indexOf('fmt_url_map:')+13;
- s=v.substring(i,v.indexOf('"',i+1)+1).split(/,|\|/);
- }
- for(;j<s.length;j+=2)
- h+='<li style="display:inline;margin-right:0.5em"><a href="'+s[j+1]+'">'+s[j]+'</a></li>';
- var a=document.getElementById('watch-description-extras');
- var b=document.createElement('h4');
- b.textContent='Download:';
- var c=document.createElement('ul');
- c.innerHTML=h;
- a.appendChild(b);
- a.appendChild(c);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement