I'm having serious trouble doing something very simple. I'd like to use a chrome extension content script to trigger the video in the following url to play:
http://sports24.club/watch?id=espn2
The following code triggers that video in the dev console:
document.getElementsByClassName('player-poster')[0].click();
Or
$('.player-poster')[0].dispatchEvent(new MouseEvent("click"));
Or
document.getElementsByTagName("video")[0].play();
I've tried some other variations, including using the "trigger" method. They also work.
However, when placed in a content script, every variation simply throws an Uncaught (in promise) DOMException.
I've looked around, and the best advice I received was from this SO question. But even that didn't work.
I would really love if any of you could explain:
Why is this happening? I get that content scripts live in their own little world, but why would that cause a .click() method to not work?
How do I get around that and make this work?
Thanks!