YouTube Converter and Downloader

Adds MP3, MP4 and 'Other' (multiple format options) download buttons to YouTube videos

  1. // ==UserScript==
  2. // @name YouTube Converter and Downloader
  3. // @version 2.0
  4. // @date 2019-07-18
  5. // @description Adds MP3, MP4 and 'Other' (multiple format options) download buttons to YouTube videos
  6. // @author SirLoinOfBeef
  7. // @copyright 2019, SirLoinOfBeef
  8. // @compatible chrome
  9. // @compatible firefox
  10. // @compatible opera
  11. // @compatible safari
  12. // @license MIT https://opensource.org/licenses/MIT
  13. // @match *://*.youtube.com/*
  14. // @match *://*.notube.net/*
  15. // @namespace https://gf.qytechs.cn/users/216347
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. if (window.location.href.indexOf("notube.net") > 0) {
  22.  
  23. //if downlaod page then download
  24. if (window.location.href.indexOf("download?token") > 0) {
  25. var FileURL = "https://s5.notube.net/download.php?token=" + window.location.href.substring(window.location.href.lastIndexOf("=") + 1);
  26. window.location.href = FileURL;
  27. setTimeout(function(){
  28. window.close();
  29. }, 2000);
  30. }
  31.  
  32. //set youtube video url
  33. var VidURL = window.location.href.substring(window.location.href.lastIndexOf("=") + 1,window.location.href.lastIndexOf("&"));
  34. document.getElementById("keyword").value = decodeURIComponent(VidURL);
  35.  
  36. //remove popup ad
  37. var curSubmit = document.getElementById("form1").querySelector('input[value="OK"]');
  38. setTimeout(function(){
  39. curSubmit.setAttribute( "onClick", "" );
  40. }, 2000);
  41.  
  42. //if starting page then set download type
  43. if (window.location.href.indexOf("DLOADMP4") > 0){document.getElementById("myDropdown").value = "mp4"}
  44. if (window.location.href.indexOf("DLOADMP3") > 0){document.getElementById("myDropdown").value = "mp3"}
  45. if (window.location.href.indexOf("DLOAD?") > 0){return}
  46.  
  47. //submit form for processing (delay required)
  48. setTimeout(function(){
  49. curSubmit.click();
  50. }, 2000);
  51.  
  52.  
  53.  
  54.  
  55. }
  56.  
  57. if (document.getElementById("polymer-app") || document.getElementById("masthead") || window.Polymer) {
  58. setInterval(function() {
  59. if (window.location.href.indexOf("watch?v=") < 0) {
  60. return false;
  61. }
  62. if (document.getElementById("count") && document.getElementById("distillvideo") === null) {
  63. Addytpolymer('MP3');
  64. Addytpolymer('MP4');
  65. Addytpolymer('?');
  66. }
  67. }, 100);
  68. } else {
  69. setInterval(function() {
  70. if (window.location.href.indexOf("watch?v=") < 0) {
  71. return false;
  72. }
  73. if (document.getElementById("watch7-subscription-container") && document.getElementById("distillvideo") === null) {
  74. AddhtmlDV();
  75. }
  76. }, 100);
  77. }
  78.  
  79. function AddhtmlDV() {
  80. if (document.getElementById("watch7-subscription-container")) {
  81. var wrap = document.getElementById('watch7-subscription-container');
  82. var button = "<div id='distillvideo' style='display: inline-block; margin-left: 10px; vertical-align: middle;'>";
  83. button += "<a href=\"https://notube.net/en?VIDURL=" + encodeURIComponent(document.URL) + "\" title=\"Download\" target=\"_blank\"" +
  84. "style=\"display: inline-block; font-size: inherit; height: 22px; border: 1px solid rgb(0, 183, 90); border-radius: 3px; padding-left: 28px; cursor: pointer; vertical-align: middle; position: relative; line-height: 22px; text-decoration: none; z-index: 1; color: rgb(255, 255, 255);\">";
  85. button += "<i style=\"position: absolute; display: inline-block; left: 6px; top: 3px; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIiB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIGlkPSJzdmcyIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJNIDQsMCA0LDggMCw4IDgsMTYgMTYsOCAxMiw4IDEyLDAgNCwwIHoiIGZpbGw9IiNmZmZmZmYiIC8+PC9zdmc+); background-size: 12px; background-repeat: no-repeat; background-position: center center; width: 16px; height: 16px;\"></i>";
  86. button += "<span style=\"padding-right: 12px;\">Download</span></a></div>";
  87. var style = "<style>#distillvideo button::-moz-focus-inner{padding:0;margin:0}#distillvideo a{background-color:#15388c}#distillvideo a:hover{background-color:#E91E63}#distillvideo a:active{background-color:rgb(0, 151, 74)}</style>";
  88. var tmp = wrap.innerHTML;
  89. wrap.innerHTML = tmp + button + style;
  90. }
  91. }
  92.  
  93. function Addytpolymer(ButtLabel) {
  94. var buttonDiv = document.createElement("span");
  95. buttonDiv.style.width = "100%";
  96. buttonDiv.style.color = "#15388c";
  97. buttonDiv.id = "distillvideo";
  98. var addButton = document.createElement("a");
  99. addButton.appendChild(document.createTextNode(ButtLabel));
  100. addButton.style.width = "100%";
  101. addButton.style.backgroundColor = "#15388c";
  102. addButton.style.color = "white";
  103. addButton.style.textAlign = "center";
  104. addButton.style.padding = "5px 10px";
  105. addButton.style.margin = "0px 10px";
  106. addButton.style.fontSize = "14px";
  107. addButton.style.border = "0";
  108. addButton.style.cursor = "pointer";
  109. addButton.style.borderRadius = "2px";
  110. addButton.style.fontFamily = "Roboto, Arial, sans-serif";
  111. addButton.style.textDecoration = "none";
  112. addButton.href = "https://notube.net/en?VIDURL=" + encodeURIComponent(document.URL) + '&DLOAD' + ButtLabel;
  113. addButton.target = "_YTD";
  114. if (ButtLabel == 'MP3'){
  115. buttonDiv.style.padding = "0px 0px 0px 20px";
  116. //buttonDiv.appendChild(document.createTextNode(' Download:' ))
  117. }
  118. buttonDiv.appendChild(addButton);
  119. var targetElement = document.querySelectorAll("[id='count']");
  120. for (var i = 0; i < targetElement.length; i++) {
  121. if (targetElement[i].className.indexOf("ytd-video-primary-info-renderer") > -1) {
  122. targetElement[i].appendChild(buttonDiv);
  123. }
  124. }
  125. }
  126.  
  127.  
  128. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址