title: GM_registerMenuCommand is not defined
body: <p>everybody. I'm puzzled as to why I keep getting the error "GM_registerMenuCommand is not defined" when I try to run a userscript that I created. I have tried this in Firefox using Scriptish 1.0b9 and the latest version of Greasemonkey. I even disabled all addons except Scriptish to see if it was a conflict, but with no joy. </p>
  
  <p>I'm including jQuery in my userscript using <a href="http://erikvold.com/blog/index.cfm/2010/6/14/using-jquery-with-a-user-script" rel="nofollow">this template by Erik Vold</a>. Before trying this template, I put the exact same code block in the template proposed by Joan Piedra and everything worked fine. Unfortunately, Piedra's template did not work in Chrome, which is something that I think is necessary, considering Chrome's growing userbase. The snippet that's throwing the error is below:</p>
  
  <pre><code>    // a function that loads jQuery and calls a callback function when jQuery has finished loading
  function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js");
    script.addEventListener('load', function() {
      var script = document.createElement("script");
      script.textContent = "(" + callback.toString() + ")();";
      document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
  }
  
  // the guts of this userscript
  function main() {
  
  
  var isLevelupMove = false;
  var isTutorMove = false;
  var isTM = false;
  var TMhead = $('#moves\\:machine');
  var hasSecondEvo = false;
  var hasFinalEvo1 = false;
  var hasFinalEvo2 = false;
  var header = $('.header-row').eq(1);
  var TMmoves = new Array();
  
  //This section deals with the user-defined colors 
  
  GM_registerMenuCommand("Color for pre-evolutionary-only moves", prevoColorPrompt);
  GM_registerMenuCommand("Color for first evolution-only moves", evoColorPrompt);
  
  if(localStorage.getItem('prevoColor') == null || localStorage.getItem('evoColor') == null)
  {
      localStorage.setItem('prevoColor', 'red');
      localStorage.setItem('evoColor', 'orange');
  }
  var prevoColor = localStorage.getItem('prevoColor');
  var evoColor = localStorage.getItem('evoColor');
  
  function prevoColorPrompt()
  {
      var input = prompt("Please enter a desired 6-digit hex color-code for pre-evolutionary pokemon:") 
      localStorage.setItem('prevoColor', '#'+input);
  }
  
  function evoColorPrompt()
  {
      var input = prompt("Please enter the desired 6-digit hex color-code for first-evolution pokemon:") 
      localStorage.setItem('evoColor', '#'+input);
  }
  
  //This loop tests each 'th' element in a sample header row, determining how many Evos are currently present in the chart.
  
  $('.header-row').eq(1).find('th').each(function(index) 
  {
      if($(this).find('a').length != 0)
      {
          switch(index)
          {
              case 2:
              hasSecondEvo = true;
              break;
  
              case 3:
              hasFinalEvo1 = true;
              break;
  
              case 4:
              hasFinalEvo2 = true;
              break;
          }
      }
  });
  
  //All 'tr' siblings are TM moves, since it's the last section on the page
  //This array puts only the names of the available TMs into the TMmoves array
  TMhead.nextAll().each(function(index)
  {
      TMmoves.push($(this).children(":first").find('a').eq(0).html());
  });
  
  $('tr').each(function(index) 
  {
      var moveName = $(this).children(":first").find('a').eq(0).html();   
      moveName = $.trim(moveName);
  
      switch($(this).attr('id'))
      {
          case 'moves:level-up':
              isLevelupMove = true;   
              break;
  
          case 'moves:egg':
              isLevelupMove = false;
              break;  
  
          case 'moves:tutor':
              isTutorMove = true;
  
          case 'moves:machine':
              isTM = true;    
      }
  
      if(isLevelupMove || isTutorMove)
      {
          var babyMoveCell = $(this).find('td').eq(0);
          babyMoveText = $.trim(babyMoveCell.html());
  
          secondEvoCell = babyMoveCell.next();
          secondEvoText = $.trim(secondEvoCell.html());
  
          finalEvo1Cell = secondEvoCell.next();
          finalEvo1Text = $.trim(finalEvo1Cell.html());
  
          finalEvo2Cell = finalEvo1Cell.next();
          finalEvo2Text = $.trim(finalEvo2Cell.html());
  
          //This checks if evolutions have checkmarks
  
          if(babyMoveText.length &gt; 0)
          {
              if(hasSecondEvo &amp;&amp; secondEvoText.length == 0 || hasFinalEvo1 &amp;&amp; finalEvo1Text.length == 0 || 
                  hasFinalEvo2 &amp;&amp; finalEvo2Text.length == 0)
              {
                  //See if the move is a TM before proceeding 
                  var tm = tmCheck(moveName);
  
                  if(!tm)
                  {
  
                      if(secondEvoText.length &gt; 0)
                      {       
                          babyMoveCell.css("color", evoColor);
                          secondEvoCell.css("color", evoColor);
                          babyMoveCell.prev().find('a').eq(0).css("color", evoColor); //highlights move name
                      }
                      else
                      {
                          babyMoveCell.css("color", prevoColor);
                          babyMoveCell.prev().find('a').eq(0).css("color", prevoColor);
                      }
                  }
              }
          }
          else if(secondEvoText.length &gt; 0)
          {
              if(hasFinalEvo1 &amp;&amp; finalEvo1Text.length == 0 || hasFinalEvo2 &amp;&amp; finalEvo2Text.length == 0)
              {
                  var tm = tmCheck(moveName); 
  
                  if(!tm)
                  {
                      secondEvoCell.css("color", evoColor);
                      babyMoveCell.prev().find('a').eq(0).css("color", evoColor);
                  }
              }
          }
      }
  
  });
  
  function tmCheck(input)
  {
      var isTM = false;
  
      //Iterate through TMmoves array to see if the input matches any entries
      for(var i = 0; i &lt; TMmoves.length; i++)
      {   
          if(input == TMmoves[i])
          {
              isTM = true;
              break;
          }
      }
  
      if(isTM == true)
          return true;
      else
          return false;       
  }
  
  //alert("evoColor: " + localStorage.getItem('evoColor') + ". prevoColor: " + localStorage.getItem('prevoColor'))
  
  }//end main()
  
  // load jQuery and execute the main function
  addJQuery(main);
  </code></pre>
  
  <p><a href="http://userscripts.org/scripts/show/98824" rel="nofollow">This is the userscript I'm trying to implement this for</a>. If anyone has any suggestions or ideas about why I'm getting the error, I'd love to hear them!</p>