-2

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?

TotalOne
  • 7
  • 3

1 Answers1

0

Just do simple query for that element and get text:

document.querySelector('#visit-advertiser:j .ytp-ad-button-text').textContent
Justinas
  • 41,402
  • 5
  • 66
  • 96
  • It's not that simple. This is just the button Text the correct URL gets generated somewhere in the client. – TotalOne Sep 16 '22 at 08:22
  • @TotalOne So then provide minimal example, not just screenshot of random HTML. JS can't read variables that are hidden from main scope – Justinas Sep 16 '22 at 08:43