Adding a click event to the youtube, without using their api

I think what I would be doing here is:

Adding a click event to the iframe

I was just told to try:
mousedown event

But how exactly would this be done?

How would you add a ‘click’ or ‘mousedown’ event to the youtube, without using their api?

added: onPlayerStateChange: The borders and lines change colors after it’s clicked.

/* function onPlayerStateChange(evt) {
    // possible states values are:
    // -1 (unstarted), 0 (ended), 1 (playing),
    // 2 (paused), 3 (buffering), 5 (video cued).
    const state =;
    if (state > 0) {


"onStateChange": onPlayerStateChange */

With ‘onPlayerStateChange’ removed, how would I get it to work the same way, but without using their api?

removed: onPlayerStateChange

When the video is clicked, the border and lines should change colors.

Javascript color code

  const wrapper = document.querySelector(".wrapg");

  function changeColor() {

  function colorClickHandler() {

  wrapper.addEventListener("click", colorClickHandler);