title: JavaScript count all elements on a webpage
body: <p>I want to be able to count everything on a site that contains a certain string, even if it's not displayed on the page.</p>
  
  <p><strong>I found this:</strong></p>
  
  <pre><code>window.occurrencesFunc()
  </code></pre>
  
  <p>I am not sure how to use it. I did play around with it, but nothing seemed to work.</p>
  
  <p><strong>This is what I tried:</strong></p>
  
  <pre><code>function main() {
      function(r) {
          var amount = window.occurrencesFunc(r, "string", false);
          $('ul.reset').append('Count: ' + amount);
      }
  }
  
  main();
  </code></pre>