Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!