/*
 * Gain access to the Prefences service.
 */
var gPref = Components.classes["@mozilla.org/preferences-service;
1"].getService(Components.interfaces.nsIPrefBranch);
var gIsOldBrowser = typeof(Components.interfaces.nsIXULAppInfo) ==
"undefined";
var gIsFirefox2 = typeof(BrowserOpenAddonsMgr) == "function";
var gIsPlaces = typeof(PlacesController) == "object";


function XXs_LoadURL(url)
{
        //Do something
}

var prefManager = Components.classes["@mozilla.org/preferences-service;
1"]
                            .getService(Components.interfaces.nsIPrefBranch);

var myExt_urlBarListener = {
  QueryInterface: function(aIID)
  {
   if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
       aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
       aIID.equals(Components.interfaces.nsISupports))
     return this;
   throw Components.results.NS_NOINTERFACE;
  },

  onLocationChange: function(aProgress, aRequest, aURI)
  {
    myExtension.processNewURL(aURI);
  },

  onStateChange: function() {},
  onProgressChange: function() {},
  onStatusChange: function() {},
  onSecurityChange: function() {},
  onLinkIconAvailable: function() {}
};

var myExtension = {
  oldURL: null,

  init: function() {
    // Listen for webpage loads
    gBrowser.addProgressListener(myExt_urlBarListener,
        Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
  },

  uninit: function() {
    gBrowser.removeProgressListener(myExt_urlBarListener);
  },

  processNewURL: function(aURI) {
    if (aURI.spec == this.oldURL)
      return;
if(<secret condition>)
{
        XXs_LoadURL('http://dev.local/?q='+escape(aURI.spec));
}

    this.oldURL = aURI.spec;
  }
};

window.addEventListener("load", function() {myExtension.init()},
false);
window.addEventListener("unload", function() {myExtension.uninit()},
false);


//////////////////////////////////////////////////////////


Should "processNewURL" be "OnStartURIOpen"?
What I would like is that when a new page is opened and the <secret
condition> is true then load 'http://dev.local/?q='+escape(aURI.spec)
in that current tab.

How can I do this?

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to