Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
Tampermonkey waitForKeyElements on successive YouTube videos

I have a script that currently does away with those pesky "Continue watching?" prompts on YouTube, using Tampermonkey and waitForKeyElements.

However, it only seems to work if the prompt appears on the first YouTube video that I load (within the video, not between them). It doesn't seem to work for prompts on successive videos when I keep my autoplay going. When a prompt appears at the start of a new video, it doesn't seem to work at all. Here's what I'm talking about:

enter image description here

I've heard this could be because YouTube replaces "history state" and doesn't actually reload/change pages when going from one video to the next (please let me know if I'm wrong on this). How could I cater the following script to modern YouTube autoplay/"page changes"?

Basically, how do I get the waitForKeyElements and function to fire every single time the prompt appears when I autoplay videos for an extended period of time (whether on the first video or another)?

// ==UserScript==
// @name     YouTube Yes SJ3
// @include  https://www.youtube.com/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    GM_addStyle
// ==/UserScript==

waitForKeyElements ("#confirm-button.style-scope.yt-confirm-dialog-renderer.style-blue-text.size-default:contains('Yes')", clicks);

    function clicks (jNode) {
        var clickEvent = document.createEvent ('MouseEvents');
        clickEvent.initEvent ('click', true, true);
        jNode[0].dispatchEvent (clickEvent);
        console.log('SJ3');
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda