There is an iframe
on this page I want to get a screenshot from the video
tag, so I have to reach video tag that in the iframe
tag.
When I open the console and run this code:
const videoElement = document.getElementsByTagName('iframe')[0]
.contentWindow.document.getElementsByTagName('video')[0];
//Extracting picture from video tag
const canvas = document.createElement('canvas');
canvas.width = videoElement.videoWidth;
canvas.height = videoElement.videoHeight;
canvas.getContext('2d').drawImage(videoElement, 0, 0, canvas.width, canvas.height);
This error has been thrown:
Uncaught DOMException: Blocked a frame with origin "https://developers.google.com" from accessing a cross-origin frame.
at <anonymous>:1:57
Also, I checked this question
My question is how can I get a screenshot from YouTube Player API?