Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
Can't get DOM of visible download button after site update

Injected javascript on youtube with violentmonkey in hopes to make the download button link to a yt1s with current video url. Can't get the DOM of the download button after changing video (the button in question changes / site doesn't reset but maintains the current instance from what I understand).

// ==UserScript==
// @name        Usable youtube download button
// @namespace   Violentmonkey Scripts
// @match       https://www.youtube.com/watch
// @include     https://*.youtube.com/*
// @grant       none
// @version     1.0
// @author      Nojyto
// ==/UserScript==

(function() {
    const API = "https://yt1s.com/en/youtube-to-mp3?q="
    console.log("-----------start--------------")
    function waitForElm(selector){
        return new Promise(resolve => {
            if(document.querySelector(selector)){
                return resolve(document.querySelector(selector))
            }
            const observer = new MutationObserver(mutations => {
                if(document.querySelector(selector)){
                    resolve(document.querySelector(selector))
                    observer.disconnect()
                }
            })
            observer.observe(document.body, {
                childList: true,
                subtree: true
            })
        })
    }  
    
    function updateButton(){
        waitForElm("#top-level-buttons-computed > ytd-download-button-renderer > ytd-button-renderer > a:nth-child(1)").then((url) => {
            console.log("-----------change btn--------------")
            if(url.id === "changed" || !document.body.contains(url)){
              url.remove()
              console.log("removed")
              updateButton()
              return
            }

            url.href        = API + encodeURIComponent(window.location.href)
            url.target      = "_blank"
            url.id          = "changed"
            url.style.color = "lightblue"
            
          
            console.log(url)
            console.log(url.href)
            
            //console.log(url.href)
            //console.log("-----------Script end--------------")
            //document.getElementsByTagName("tp-yt-paper-dialog")[0].remove()
            //document.getElementsByTagName("ytd-popup-container")[0].remove()
        })
    }
  
    window.onload = updateButton;
    window.addEventListener("yt-navigate-start", updateButton, true)
})()
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda