title: How to make Javascript execute when you scroll?
body: <p>I'm creating a Tampermonkey script that allows you hide subreddits from the front page of Reddit. It works all good, but only on the first page. The problem is, when you start scrolling, Reddit loads in new items (infinite scrolling) and the code doesn't work for those new items that get added.</p>
  
  <p>I tried to add an event listener, but this doesn't work. The items still appear when you are scrolling.</p>
  
  <pre><code>window.addEventListener("scroll", function(){
  
  document.querySelector('a[href*="politics"]').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.style.display='none';
  
  });
  </code></pre>