title: Fire Fox Extension (Observers) - Trigger "http-on-modify-request" only once
body: <p>In reality, I am trying to capture the event immediately after a user presses ENTER on the address bar and moments before onLocationChange. I have an observer setup by using the following link as a guide: <a href="https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/Intercepting_Page_Loads" rel="nofollow">https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/Intercepting_Page_Loads</a>, and have something similar to the below.</p>
  
  <p>However, the console print many URLs, even the images and scripts. How can I modify the code such that the function is triggered only once or gets disabled until the address bar changes or a link is clicked.</p>
  
  <p>I guess I can set my own variable to track whether a request has been triggered on the URL, but want to know if there is a more efficient solution.</p>
  
  <pre><code>var httpRequestObserver = {
      ioService: Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService),
  
      observe: function(subject, topic, data) {
                  if (topic == "http-on-modify-request") {
  
                      var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
  
                      console.log(httpChannel.URI.spec);
                  }
              },
  
      register: function() {
          this.observerService.addObserver(this, "http-on-modify-request", false);
      },
  
      unregister: function() {
          this.observerService.removeObserver(this, "http-on-modify-request");
      }
  };
  
  httpRequestObserver.register();
  </code></pre>