YouTube Download

On youtube click the download link to download youtube video.

当前为 2015-08-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Download
  3. // @namespace http://your.homepage/
  4. // @version 3.9
  5. // @description On youtube click the download link to download youtube video.
  6. // @author Henry Harris
  7. // @match https://www.youtube.com/*
  8. // @match http://9xbuddy.com/*
  9. // @grant none
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14.  
  15.  
  16.  
  17.  
  18. $(document).ready ( function(){
  19. // -----------------------Runs on YOUTUBE--------------------------------------------------------------
  20. var beforestop = false;
  21. setInterval(function(){
  22. if(window.location.href.indexOf("you") > -1) {
  23. if ($('#watch7-headline').length > 0) {
  24. if ($('#downloadlnk').length > 0) {
  25. } else {
  26. if ($('.html5-player-chrome').length > 0) {
  27. if ($('#vidctrls').length > 0) {
  28. } else{
  29. document.querySelector('div.html5-player-chrome').id = 'vidctrls';
  30.  
  31. var c = document.createElement('img');
  32. c.src = "http://upload.wikimedia.org/wikipedia/commons/thumb/c/ca/Egypt_governorates_blank.png/597px-Egypt_governorates_blank.png";
  33. c.height = "30";
  34. c.width = "10";
  35. var b = document.createElement('img');
  36. b.src = "http://images.clipartpanda.com/square-clip-art-black-and-white-0999d59a768fa638a6f16f4a44299e29.png";
  37. b.height = "30";
  38. b.width = "30";
  39. b.title = "Download this video";
  40. b.onclick = function () {
  41. window.open("http://9xbuddy.com/download?url=" + document.URL)
  42. };
  43.  
  44. document.getElementById("vidctrls").appendChild(c);
  45. document.getElementById("vidctrls").appendChild(b);
  46. }
  47. } else {
  48. var downdiv = document.createElement("div");
  49. downdiv.id = "downdiv";
  50. var a = document.createElement('a');
  51. var linkText = document.createTextNode("Download");
  52. a.appendChild(linkText);
  53. a.id = "downloadlnk";
  54. a.title = "Download this video";
  55. a.onclick = function () {
  56. window.open("http://9xbuddy.com/download?url=" + document.URL)
  57. };
  58. var br3 = document.createElement('br');
  59. document.getElementById("watch7-headline").appendChild(br3);
  60. var br4 = document.createElement('br');
  61. document.getElementById("watch7-headline").appendChild(br4);
  62. var d = document.createElement('a');
  63. var linkText = document.createTextNode("Options");
  64. d.appendChild(linkText);
  65. d.id = "optionlnk";
  66. d.title = "Options";
  67. d.onclick = function () {
  68. var e = document.body;
  69. e.parentNode.removeChild(e);
  70. var body = document.createElement('body');
  71. document.getElementsByTagName('html')[0].appendChild(body);
  72. var chk1 = document.createElement('input');
  73. chk1.type = "checkbox";
  74. chk1.id = "chk1"
  75. document.getElementsByTagName('body')[0].appendChild(chk1);
  76. var label = document.createElement('label')
  77. label.htmlFor = "chk1";
  78. label.appendChild(document.createTextNode('Auto HD'));
  79. document.getElementsByTagName('body')[0].appendChild(label);
  80. var br = document.createElement('br');
  81. document.getElementsByTagName('body')[0].appendChild(br);
  82. var br2 = document.createElement('br');
  83. document.getElementsByTagName('body')[0].appendChild(br2);
  84. var appbtn = document.createElement('input');
  85. appbtn.type = "button";
  86. appbtn.value = "Apply"
  87. appbtn.onclick = function () {
  88. if (chk1.checked == true) {
  89. document.cookie =
  90. 'autohd=test; expires=Fri, 3 Aug 2050 20:47:11 UTC; path=/'
  91. } else {
  92. document.cookie = 'autohd=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/'
  93. }
  94. location.reload();
  95. }
  96. document.getElementsByTagName('body')[0].appendChild(appbtn);
  97. if (document.cookie.indexOf('autohd=')== -1) {
  98. chk1.checked = false;
  99. } else {
  100. chk1.checked = true;
  101. }
  102. };
  103. //document.body.appendChild(a);
  104. document.getElementById("watch7-headline").appendChild(downdiv);
  105. document.getElementById("downdiv").appendChild(a);
  106. document.getElementById("downdiv").appendChild(br3);
  107. document.getElementById("downdiv").appendChild(br4);
  108. document.getElementById("downdiv").appendChild(d);
  109. document.getElementById("downloadlnk").style.fontSize = "x-large";
  110. document.getElementById("optionlnk").style.fontSize = "x-large";
  111. var br1 = document.createElement('br');
  112. document.getElementById("watch7-headline").appendChild(br1);
  113. var br2 = document.createElement('br');
  114. document.getElementById("watch7-headline").appendChild(br2);
  115. }
  116. }
  117. }
  118. }
  119.  
  120. if (document.cookie.indexOf('autohd=')== -1) {
  121. //no cookie
  122. } else {
  123. if (beforestop == false) {
  124. var myNode = document.getElementById("movie_player");
  125. while (myNode.firstChild) {
  126. myNode.removeChild(myNode.firstChild);
  127. beforestop = true;
  128. }
  129.  
  130. var url = document.URL;
  131. url = url.substring(0, url.length - 8);
  132. var vidid = url.substring(url.indexOf('=')+1);
  133. var player = document.createElement('iframe');
  134. player.id = "player1";
  135. player.width = "1920";
  136. player.height = "1080";
  137. player.src = "https://www.youtube.com/embed/" + vidid + "?rel=0&autoplay=1&VQ=HD720";
  138. player.frameborder = "0";
  139. document.getElementById("movie_player").appendChild(player);
  140. document.getElementById("player1").setAttribute("allowfullscreen", "true");
  141. setTimeout(function(){
  142. document.getElementById("player1").width = "855";
  143. document.getElementById("player1").height = "480";
  144. }, 7000);
  145. }
  146. var url = document.URL;
  147. var idtest = url.substring(url.indexOf('=')+1);
  148. alert(vidid);
  149. if (idtest === vidid){
  150. } else {
  151. }
  152. }
  153. }, 2000);
  154. setInterval(function(){
  155. if(window.location.href.indexOf("you") > -1) {
  156. if(window.location.href.indexOf("embed") > -1) {
  157. } else {
  158. if(window.location.href.indexOf("reldone") > -1) {
  159. } else {
  160. window.location.assign(document.URL + "#reldone");
  161. location.reload();
  162. }
  163. }
  164. }
  165. }, 4000);
  166. // --------------------------RUNS ON KEEPVID TO DOWNLOAD VIDEO--------------------------------------------
  167. if(window.location.href.indexOf("buddy") > -1) {
  168. /*var iDiv = document.createElement('div');
  169.  
  170. iDiv.id = 'block';
  171. iDiv.className = 'block';
  172. document.getElementsByTagName('body')[0].appendChild(iDiv);
  173. iDiv.height = window.height();
  174. iDiv.width = window.width();
  175. $(iDiv).css({
  176. position: 'fixed',
  177. top: 0,
  178. right: 0,
  179. bottom: 0,
  180. left: 0,
  181. zIndex: 999
  182. });*/
  183.  
  184.  
  185.  
  186. //if(!$('#javaUserWarning').is(':visible')) {
  187. setInterval(function(){
  188. if ($(".download-link-list")[0]){
  189. var els = document.getElementsByClassName('download-link-download lbcolor');
  190. var element = $('.download-about-section li');
  191. var zali = element[1]
  192. var zalitext = zali.innerHTML
  193. if (zalitext.match("VEVO")) {
  194. var li = els[1]
  195. li.id = 'dwnload';
  196. var t = $('#dwnload a').attr('href');
  197. } else {
  198. var li = els[2]
  199. li.id = 'dwnload';
  200. var t = $('#dwnload a').attr('href');
  201. }
  202. window.location = t
  203. setTimeout(function(){
  204. window.close();
  205. }, 2000);
  206. } else {
  207. //alert("test");
  208. }
  209. }, 3000);
  210. //document.getElementById("checkboxDisableJava1").checked = true;
  211.  
  212. // } else {
  213. // alert("Please check disable java applet and retry.");
  214. //}
  215. }
  216. });
  217.  
  218. // -----------------------Runs on YOUTUBE--------------------------------------------------------------
  219. //$(document).keydown(function (e) {
  220. // if (e.keyCode == 113) {
  221. //window.open("http://keepvid.com/?url=" + document.URL)
  222. // var a = document.createElement("a");
  223. //a.href = "http://catchvideo.net/?url=" + document.URL;
  224. //var evt = document.createEvent("MouseEvents");
  225. //evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null);
  226. //a.dispatchEvent(evt);
  227. //}
  228. //});