Hybrid YouTube Download Extension

Creates links to both youtube320 and BitDownloader.

  1. // ==UserScript==
  2. // @name Hybrid YouTube Download Extension
  3. // @description Creates links to both youtube320 and BitDownloader.
  4. // @icon https://www.youtube.com/s/desktop/4aac258c/img/favicon_96.png
  5. // @author BitDownloader, TylerWDoesStuff
  6. // @copyright 2018, BitDownloader; 2020, TylerWDoesStuff
  7. // @namespace null
  8. // @license GPL-3.0-or-later
  9. // @include http://www.youtube.com/*
  10. // @include https://www.youtube.com/*
  11. // @version 0.1.7
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. if (document.getElementById("polymer-app") || document.getElementById("masthead") || window.Polymer) {
  18. setInterval(function() {
  19. if (window.location.href.indexOf("watch?v=") < 0) {
  20. return false;
  21. }
  22. if (document.getElementById("count") && document.getElementById("bitdownloader_mp4") === null) {
  23. polymerAdd();
  24. if (document.getElementById("count") && document.getElementById("bitdownloader_mp3") === null) {
  25. PolymerAdd();
  26. }}
  27. }, 100);
  28. } else {
  29. setInterval(function() {
  30. if (window.location.href.indexOf("watch?v=") < 0) {
  31. return false;
  32. }
  33. if (document.getElementById("watch7-subscription-container") && document.getElementById("bitdownloader_mp4") === null) {
  34. htmlAdd();
  35. if (document.getElementById("watch7-subscription-container") && document.getElementById("bitdownloader_mp3") === null) {
  36. HtmlAdd();
  37. }
  38. }
  39. }, 100);
  40. }
  41.  
  42. function htmlAdd() {
  43. if (document.getElementById("watch7-subscription-container")) {
  44. var wrap = document.getElementById('watch7-subscription-container');
  45. var button = "<div id='bitdownloader_mp4' style='display: inline-block; margin-left: 10px; vertical-align: middle;'>";
  46. button += "<a href=\"https://www.y2mate.com/youtube/" + ytvid(document.URL) + "/?utm_source=BitDownloader_Extension\" title=\"Download this video\" target=\"_blank\"" +
  47. "style=\"display: inline-block; font-size: inherit; height: 22px; border: 0px solid rgb(0, 183, 90); border-radius: 5px; padding-left: 14px; cursor: pointer; vertical-align: middle; position: relative; line-height: 22px; text-decoration: none; z-index: 1; color: rgb(255, 255, 255);\">";
  48. 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>";
  49. button += "<span style=\"padding-right: 12px;\">• ↓ MP4</span></a></div>";
  50. var style = "<style>#bitdownloader button::-moz-focus-inner{padding:0;margin:0}#bitdownloader a{background-color:#15388c}#bitdownloader a:hover{background-color:#E91E63}#bitdownloader a:active{background-color:rgb(0, 151, 74)}</style>";
  51. var tmp = wrap.innerHTML;
  52. wrap.innerHTML = tmp + button + style;
  53. }
  54. }
  55.  
  56. function polymerAdd() {
  57. var buttonDiv = document.createElement("span");
  58. buttonDiv.style.width = "100%";
  59. buttonDiv.id = "bitdownloader_mp4";
  60. var addButton = document.createElement("a");
  61. addButton.appendChild(document.createTextNode(" • ↓ MP4"));
  62. addButton.style.width = "100%";
  63. addButton.style.backgroundColor = "#181818";
  64. // #15388c
  65. addButton.style.color = "#aaaaaa";
  66. addButton.style.textAlign = "center";
  67. addButton.style.padding = "0px 0px";
  68. addButton.style.margin = "0px 0px";
  69. addButton.style.fontSize = "14px";
  70. addButton.style.border = "0";
  71. addButton.style.cursor = "pointer";
  72. addButton.style.borderRadius = "0px";
  73. addButton.style.fontFamily = "Roboto, Arial, sans-serif";
  74. addButton.style.textDecoration = "none";
  75. addButton.href = "https://www.y2mate.com/youtube/" + ytvid(window.location.href) + "/?utm_source=BitDownloader_Extension";
  76. addButton.target = "_blank";
  77. buttonDiv.appendChild(addButton);
  78. var targetElement = document.querySelectorAll("[id='count']");
  79. for (var i = 0; i < targetElement.length; i++) {
  80. if (targetElement[i].className.indexOf("ytd-video-primary-info-renderer") > -1) {
  81. targetElement[i].appendChild(buttonDiv);
  82. }
  83. }
  84. }
  85.  
  86. function ytvid(url) {
  87. var p = /((http|https)\:\/\/)?(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
  88. return (url.match(p)) ? RegExp.$3 : false;
  89. }
  90.  
  91. function HtmlAdd() {
  92. if (document.getElementById("watch7-subscription-container")) {
  93. var wrap = document.getElementById('watch7-subscription-container');
  94. var button = "<div id='bitdownloader_mp3' style='display: inline-block; margin-left: 10px; vertical-align: middle;'>";
  95. button += "<a href=\"https://www.320youtube.com/v7/watch?v=" + ytvid(document.URL);
  96. "style=\"display: inline-block; font-size: inherit; height: 22px; border: 0px solid rgb(0, 183, 90); border-radius: 5px; padding-left: 14px; cursor: pointer; vertical-align: middle; position: relative; line-height: 22px; text-decoration: none; z-index: 1; color: rgb(255, 255, 255);\">";
  97. 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>";
  98. button += "<span style=\"padding-right: 12px;\">• ↓ MP3</span></a></div>";
  99. var style = "<style>#bitdownloader button::-moz-focus-inner{padding:0;margin:0}#bitdownloader a{background-color:#15388c}#bitdownloader a:hover{background-color:#E91E63}#bitdownloader a:active{background-color:rgb(0, 151, 74)}</style>";
  100. var tmp = wrap.innerHTML;
  101. wrap.innerHTML = tmp + button + style;
  102. }
  103. }
  104.  
  105. function PolymerAdd() {
  106. var buttonDiv = document.createElement("span");
  107. buttonDiv.style.width = "100%";
  108. buttonDiv.id = "bitdownloader_mp3";
  109. var addButton = document.createElement("a");
  110. addButton.appendChild(document.createTextNode(" • ↓ MP3"));
  111. addButton.style.width = "100%";
  112. addButton.style.backgroundColor = "#181818";
  113. // #15388c
  114. addButton.style.color = "#aaaaaa";
  115. addButton.style.textAlign = "center";
  116. addButton.style.padding = "0px 0px";
  117. addButton.style.margin = "0px 0px";
  118. addButton.style.fontSize = "14px";
  119. addButton.style.border = "0";
  120. addButton.style.cursor = "pointer";
  121. addButton.style.borderRadius = "0px";
  122. addButton.style.fontFamily = "Roboto, Arial, sans-serif";
  123. addButton.style.textDecoration = "none";
  124. addButton.href = "https://www.320youtube.com/v7/watch?v=" + ytvid(window.location.href);
  125. addButton.target = "_blank";
  126. buttonDiv.appendChild(addButton);
  127. var targetElement = document.querySelectorAll("[id='count']");
  128. for (var i = 0; i < targetElement.length; i++) {
  129. if (targetElement[i].className.indexOf("ytd-video-primary-info-renderer") > -1) {
  130. targetElement[i].appendChild(buttonDiv);
  131. }
  132. }
  133. }
  134.  
  135.  
  136. })();

QingJ © 2025

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