Skip to content Skip to sidebar Skip to footer

On A Youtube Video Page, How Do I Check If The Video Is Currently Playing An Ad Or The Actual Video Via Javascript?

I'm writing a chrome extension that displays content synced with the video. I need to wait until the viewer finishes the ad/midroll before displaying the content. How do I do somet

Solution 1:

Solution!

if (document.querySelector("div.ad-showing")) {
           //Ad is active as a video console.log("this is an ad")
        }
        else {
console.log("the video is playing")
}
}

Enjoy everyone!

Post a Comment for "On A Youtube Video Page, How Do I Check If The Video Is Currently Playing An Ad Or The Actual Video Via Javascript?"