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

169
Visualizações
Click not working on youtube button to play video with chrome extension

I'm writing an extension for watching videos on YouTube. A site opens with a timer in which the YouTube iframe is located. I just need to play the video. I do it with a click. The problem is that it doesn't work. Access to the iframe is in the manifest. The click happens, the screen blinks for a second, and nothing happens. It is interesting that sometimes it works without problems. I do not understand what the problem is.

manifest.json:
{
    "manifest_version": 2,
    "name": "test",  
    "description": "test",  
    "version": "1.0",    
    "permissions": ["tabs","storage","<all_urls>","activeTab"],  
    "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["background.js"],
      "run_at": "document_end",
      "all_frames": true
    }
    ],
}

bacground.js:

const delay = millis => new Promise((resolve, reject) => {
setTimeout(_ => resolve(), millis)
});
async function test(){
var url = window.location.toString();
var ytframe = "www.youtube.com/embed";
var resultytframe = url.match(ytframe);
   if(resultytframe==ytframe){
      document.querySelectorAll("button[class='ytp-large-play-button ytp-button']")[0].click();
   }
}
test();

Also, everything will work if I make a physical mouse click anywhere(besides the play button) or write something to the console before work background.js. Video for example: https://youtu.be/rlf0eVyPf8w

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to turn on the sound for YouTube in the browser settings. This problem arose in my Brave browser on Chromium: 89.0.4389.72, I decided to check it in Google Chrome browser on Chromium 102.0.5005.63, there is no such problem and you can turn off the sound

about 4 years ago · Juan Pablo Isaza Relatório
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