title: Having trouble with basic greasemonkey script - GM.getValue / GM.setValue (I think)
body: <p>I'm trying to write a basic Greasemonkey script but I'm running into some problems. Essentially, the script will refresh the page and count the number of images on a page. If the number of images increased, it will alert me and make that tab active. If the number of images are the same or less, it will continue refreshing the page at set intervals. </p>
  
  <p>I think that the best course of action, based on what I've looked at, would be to use GM.getValue / GM.setValue in order to store the number of images to compare it with the new image count. I just can't seem to get it to even run though - I think my logic is sound, but it's just a syntax issue despite trying different variations. I've never used Javascript before!</p>
  
  <pre><code>// ==UserScript==
  // @name        *Page Refresher
  // @include     *
  // ==/UserScript==
  // @grant    GM.getValue
  // @grant    GM.setValue
  
  var refreshRate = 10000; //Refreshes every 10s
  var newCount =document.images.length; //Counts images on page
  
  if (GM.getValue('oldCount',-1) === -1){
    GM.setValue('oldCount',newCount);
    window.setTimeout(function(){window.location.reload() ;},refreshRate);
  } else {
    if (newCount &lt;= GM.getValue('oldCount')){
        GM.setValue('oldCount',newCount);
        window.setTimeout(function(){window.location.reload() ;},refreshRate);
  } else {
       if (newCount &gt; GM.getValue('oldCount')){
           GM.setValue('oldCount',newCount);
           alert('More images!');
        }
  }
  </code></pre>
  
  <p>That's the rough code I'm working with. I'm just not really sure where I'm going wrong - I'm sure it's something pretty straightforward, but I'm definitely struggling. Thank you!</p>