title: LocalStorage in Greasemonkey
body: <p>I've started writing a greasemonkey script, and am facing problems performing localstorage in the Greasemonkey script. The only way I could figure out localstorage in GM is by creating another instance of Javascript in the <code>newElement.innerHTML</code> DOM property, but there the rest of my variables are inaccessible.</p>
  
  <p>Any ideas ? Here's the Greasemonkey code fragment I'm working on.</p>
  
  <pre><code>        var testHref = anchorTag[i].href;
      var testHTML = anchorTag[i].innerHTML;
      var patHref = /item\?id=[0-9]*/g;
      var patCaptureId = /item\?id=([0-9]*)/g;
      var testId = patCaptureId.exec(testHref);
      var patHTML = /[0-9]* comment(|s)/g;
      var patHTML2 = /discuss/g;
      if(patHref.test(testHref) &amp;&amp; !patHTML.test(testHTML) &amp;&amp; !patHTML2.test(testHTML))
      {
          newElement = document.createElement('span');
          newElement.style.color = "#FF0000";
          newElement.innerHTML = "&lt;a href=\"javascript:localStorage.setItem( 'one', 'rishabhVerma' ); var test = localStorage.getItem( 'one' ); console.log( test );\"&gt; B&lt;/a&gt;";
          anchorTag[i].parentNode.insertBefore(newElement, anchorTag[i].nextSibling); 
      }
      i++;
  </code></pre>