-2

I have an iframe youtube video, where i want to remove an div element. I can do it in in the console as long I manually folded out the div which I am looking for, but otherwise i am not able to find it using document.getElementByClassName()..

Is it possible via js to somehow remove an div which resides inside #document?

anita
  • 193
  • 10
  • no such thing as `getElementByClassName` - it's `getElementsByClassName` – Pete Jan 24 '19 at 16:51
  • Even if this was possible, you would likely be breaking YouTube's terms of use by modifying their player. – Turnip Jan 24 '19 at 17:05

1 Answers1

0

No.

JavaScript running in a page containing an iframe element can't access the DOM of a cross-origin site loaded into that iframe.

You can send messages using postMessage, but YouTube has no API for removing arbitrary elements from the DOM in response to a message.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335