0

I am trying to detect the status of the "More video's" bar in the Youtube, the one that shows when you press pause, there are two options there. Or the bar is visible or not and the button just shows. (display:block or display:none) I would like to know when the button shows, this means that the uses has minimized the "more videos" bar.

Important here to note is that is cross-domain so the Cors will block changes but does it also block if just request the information? To keep it close to the core I only want to use vJavascript.

this would be the option to search for an element but instead of changing it i would like to know the status (display:block or display:none)

var iframe = document.getElementById("myFrame");
var elmnt = iframe.contentWindow.document.getElementsByTagName("H1")[0];
elmnt.style.display = "none";

important to note is as well, that the Youtube-Api is used, so I am not adding the iFrame myself on the page. However the request can be send later once the iframe has loaded.

It's this div that I am curious of to know:

<iframe id="player" frameborder="0" allowfullscreen="1" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" 
title="YouTube video player" width="960" height="408" src="https://www.youtube.com/embed/xxx?enablejsapi=1&amp;origin=http%3A%2F%2Flocalhost%3A46916&amp;widgetid=1">
#document
<body>
 <div id="player" ....
   <div class="class="html5-video-player .....
     <div class="ytp-pause-overlay ytp-scroll-min"...
 ...
</body>
</iframe>
Ewald Bos
  • 1,560
  • 1
  • 20
  • 33

1 Answers1

1

You're not even allowed to read from a frame from another domain. You need to proxy the request through your own server and play with the content before returning your response. Just to be clear, there's no client-side only, JavaScript solution.

Richard Uie
  • 141
  • 4