Extract Youtube ad-button Link with javascript

Viewed 18

I need to extract a link that is generated on the client side when clicking a button.

enter image description here Youtube Ad Button

When clicking the button the browser opens a new page and redirects the user to the advertiser. How can I get this link?

1 Answers

Just do simple query for that element and get text:

document.querySelector('#visit-advertiser:j .ytp-ad-button-text').textContent
Related