I'm currently making a browser extension, and I need it to find the URL of an ad that is on the screen playing in YouTube. How can I do this in JavaScript?
I've found something called 'adVideoId' in the body tag of a page containing a video ad, which I think is a JavaScript object variable, but I can't seem to actually extract its value.
Note: the 'adVideoId' is at the end of the code below.
<body dir="ltr" standardized-themed-scrollbar=""><div id="watch7-content" class="watch-main-col" itemscope="" itemid="" itemtype="http://schema.org/VideoObject"><link itemprop="url" href="https://www.youtube.com/watch?v=l1YwPDTsLJ"><meta itemprop="name" content="I Went UNDERCOVER in a Tournament!"><meta itemprop="description" content="Undercover in a Raider Only! SUBSCRIBE & CLICK THE BELL! 🔔Merch: https://..."><meta itemprop="videoId" n27r_zAhXjp1EKHZpXDrI="}},"hoverText":{"simpleText":"Why this ad?"},"trackingParams":"CDgQs-4CIhMIrdfp9u6_8wIV46dRCh2aVw6y"}},"adVideoId":"d40g6ewFE-k","impressionPings":[{"base
var ytInitialPlayerResponse = {"responseContext":{"serviceTrackingParams [shortened here because it is ridiculously long] "adVideoId":"sEVvXIQ_DLY"