Youtube Download

Añade dos botones a youtube para descargar MP4 y MP3

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Youtube Download
// @namespace YoutubeDownload
// @description Añade dos botones a youtube para descargar MP4 y MP3
// @author tejonaco
// @contributionURL Bitcoin:3M93ygVV3RfL9M9dRJNcxaj3szuk3z5GZa
// @version 1.1
// @date 2021-02-07
// @icon https://i.pinimg.com/originals/f0/bf/e6/f0bfe6f3b051934eb67b1b49e9481be4.png
// @match *://*.youtube.com/*
// ==/UserScript==

// SECONDS TO UPDATE VIDEO
videoUpdateTime = 5


terminado = false;
url = document.URL

if (!url.match('.+youtube.com/watch.+')){  // PARA LA NAVEGACION EN OTRAS PAGINAS
  terminado = true
}


// EJECUTAR CUANDO ENCUENTRE EL BOTON
setInterval(function() {
  // DETECTAR CAMBIO DE VIDEO
    if (url != document.URL){
      url = document.URL
      terminado = false
    }
  
    if (!terminado){
      descripcion = document.querySelector('ytd-video-owner-renderer.ytd-video-secondary-info-renderer')
      hueco_descarga = document.createElement('div')

      if(descripcion){
        hueco_descarga.style.display = 'contents'
        hueco_descarga.style['text-align'] = 'center'
        
        // IDENTIFICADOR VIDEO
        regex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
        match = String(url).match(regex);
        video_id = match[7]
        
        add_boton('▼', 'https://www.ytdownfk.com/search?url=' + video_id);
        descripcion.appendChild(hueco_descarga)
        
        terminado = true
      }
    }
  }, videoUpdateTime  * 1000)

  

// AÑADIR BOTON
function add_boton(texto, link) {
  if (!document.getElementById(texto)){
    funcion_click = "window.open(\'" + link + "\')"
    hueco_descarga.innerHTML += ' <tp-yt-paper-button subscribed onclick="' + funcion_click + '" id="' + texto + '" target="_blank" style="display:inline; vertical-align: middle" class="ytd-subscribe-button-renderer"><a style="text-decoration: none; color: inherit;" class="style-scope ytd-subscribe-button-renderer">' + texto + '</a></paper-button>';
  }else{
    // CAMBIAR EL ENLACE SIN AÑADIR UN NIEVO BOTON
    document.getElementById(texto).onclick = function() {
    window.open(link)
    }
  }
};