title: How to run a script every time a new page is loaded on YouTube?
body: <p>Since some time last year, YouTube made it so that every page is not actually loading an entirely new page, but primarily just re-loading the contents in <code>div#content</code>. You can notice this when you click on a link in YouTube and see the red loading bar at the top of the page. </p>
  
  <p>I have a Greasemonkey script that modified elements on YouTube, but now that YouTube doesn't reload the entire page, the Greasemonkey script no longer fires on every "new" page. How can I make the Greasemonkey script fire on every "new" page that I load on YouTube?</p>
  
  <p>I'm using jQuery in this Greasemonkey script. I tried using functions like <code>.on()</code> with <code>DOMNodeInserted</code> but I can't find the right combination to make it work properly. With the event listeners that I've been using, I end up running my script hundreds of times for each page load, such as with the following:</p>
  
  <p><code>$('div#page').on('DOMNodeInserted', 'div#content', function() { });</code></p>
  
  <p>Another solution I was thinking of was making all links on YouTube load pages like normal, without the new way that they are doing it.</p>