0

I'm trying to make a chrome extension that will add HTML code to YouTube but when I try adding HTML code, the YouTube website just blackout. I want to add my code on top of YouTube already existing HTML code.

if(window.location.href.includes('youtube.com')) {
    document.querySelector('body').innerHTML += `<h1>Hello</h1>`;
}
  • Don't ever append to innerHTML of a site's body because it's destroying all of its dynamically added event listeners, see [Is it possible to append to innerHTML without destroying descendants' event listeners?](https://stackoverflow.com/q/595808) for alternatives. – wOxxOm Jul 13 '23 at 05:59

0 Answers0