Advertisement
0x3c0

Untitled

Apr 24th, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           YouTube downloader
  3. // @namespace      http://concentratedentropy.wordpress.com/
  4. // @description    Download videos
  5. // @include        http://*.youtube.com/watch?v=*
  6. // ==/UserScript==
  7.  
  8. var s,h='',j=0;
  9. if(document.getElementById('movie_player'))
  10. {//not html5 mode
  11. var f=document.getElementById('movie_player').getAttribute('flashvars');
  12. var i=f.indexOf('&fmt_url_map=')+13;
  13. s=unescape(f.substring(i,f.indexOf('&',i))).split(/,|\|/);
  14. }
  15. else
  16. {
  17. var v=unsafeWindow.videoPlayer.toSource();
  18. var i=v.indexOf('html5_fmt_map:#')+17;
  19. var x=eval(v.substring(i,1+v.indexOf(']',i)));//>eval
  20. x.map(function(o){h+='<li style="display:inline;margin-right:0.5em"><a href="'+o.url+'">'+o.itag+'</a></li>';});
  21. i=v.indexOf('fmt_url_map:')+13;
  22. s=v.substring(i,v.indexOf('"',i+1)+1).split(/,|\|/);
  23. }
  24.  
  25. for(;j<s.length;j+=2)
  26. h+='<li style="display:inline;margin-right:0.5em"><a href="'+s[j+1]+'">'+s[j]+'</a></li>';
  27. var a=document.getElementById('watch-description-extras');
  28. var b=document.createElement('h4');
  29. b.textContent='Download:';
  30. var c=document.createElement('ul');
  31. c.innerHTML=h;
  32. a.appendChild(b);
  33. a.appendChild(c);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement