title: Watch for element creation in greasemonkey script?
body: <p>I need to be notified when an element with class 'nav' is created as the document is loading. Googling I found MutationObservers and thought they would be perfect, but I can't seem to get it working.</p>
  
  <pre><code>// ==UserScript==
  // @name        ii-shortcuts
  // @namespace   https://github.com/RedHatter
  // @include     *
  // @version     1
  // @run-at document-start
  // ==/UserScript==
  
  var observer = new MutationObserver(function(mutations)
  {
      mutations.forEach(function(mutation)
      {
          if (mutation.target.getAttribute('class') == 'nav')
              GM_log('nav creation');
      });    
  });
  observer.observe(document, {subtree: true, attributes: true, attributeFilter: ['class']});    
  </code></pre>
  
  <p>I also tried.</p>
  
  <pre><code>// ==UserScript==
  // @name        ii-shortcuts
  // @namespace   https://github.com/RedHatter
  // @include     *
  // @version     1
  // @run-at document-start
  // ==/UserScript==
  
  var observer = new MutationObserver(function(mutations)
  {
      mutations.forEach(function(mutation)
      {
          if (mutation.addedNodes[0].getAttribute('class') == 'nav')
              GM_log('nav creation');
      });    
  });
  observer.observe(document, {subtree: true, childList: true});
  </code></pre>
  
  <p>But in nether case was 'nav creation' log on page load. What am I missing?</p>