title: Add to a hrefs of certain class using javascript
body: <p>This is my code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function pagechangefl() {
    var list1 = document.getElementsByClassName("fl");
    for (var k = 0; k &lt; list1.length; k++) {
      var str1 = list1[k].href;
      var str2 = "&amp;num=100";
      if (!(str1.endsWith("&amp;num=100"))) {
        list1[k].href = str1 + str2;
      }
    }
  }
  
  function pagechangepn() {
    var list2 = document.getElementsByClassName("pn");
    for (var i = 0; i &lt; list2.length; i++) {
      var str3 = list2[i].href;
      var str4 = "&amp;num=100";
      if (!(str3.endsWith("&amp;num=100"))) {
        list2[i].href = str3 + str4;
      }
    }
  }
  
  var t1 = setInterval(pagechangefl, 1000);
  var t2 = setInterval(pagechangepn, 1000);</code></pre>
  </div>
  </div>
  </p>
  
  <p>The problem of the current code is that I don't want to use a timer I want these functions to run everytime the page is updated with # links example. Even with a timer the pagechangefl function doesn't add the addition for some reason.</p>
  
  <p><a href="https://www.google.com/search?q=test&amp;tbs=cdr:1,cd_min:0000&amp;start=000&amp;tbm=bks&amp;num=100" rel="nofollow noreferrer">https://www.google.com/search?q=test&amp;tbs=cdr:1,cd_min:0000&amp;start=000&amp;tbm=bks&amp;num=100</a></p>
  
  <p>vs</p>
  
  <p><a href="https://www.google.com/search?q=test&amp;tbs=cdr:1,cd_min:0000&amp;start=000&amp;tbm=bks&amp;num=100#q=test&amp;tbs=cdr:1,cd_min:0000&amp;tbm=bks&amp;start=100&amp;num=100" rel="nofollow noreferrer">https://www.google.com/search?q=test&amp;tbs=cdr:1,cd_min:0000&amp;start=000&amp;tbm=bks&amp;num=100#q=test&amp;tbs=cdr:1,cd_min:0000&amp;tbm=bks&amp;start=100&amp;num=100</a></p>