views:

258

answers:

1

I am developing a small extension that has to redirect certain URLs to another Site. It's working fine, except for one situation: if open the Link with "Context-Menu -> Open in new Tab", the current page is redirectet to my page and a second tab opens with the link that should be redirected. What am I making wrong? Is there a better way to achieve what I want?

var myListener =
{
    QueryInterface: function(iid)
     {
         if (iid.equals(Components.interfaces.nsIURIContentListener) ||
          iid.equals(Components.interfaces.nsISupportsWeakReference) ||
             iid.equals(Components.interfaces.nsISupports))
             return this;
         throw Components.results.NS_NOINTERFACE;
     },
     onStartURIOpen: function(aUri)
     {
            if (check_url(aUri)) {
                getBrowser().mCurrentTab.linkedBrowser.loadURI(######REDIRECT IS HERE#############);
                return true;
            }
            return false;
     },
     doContent: function(aContentType, aIsContentPreferred, aRequest, aContentHandler )
     {
           throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
     },
     canHandleContent: function(aContentType, aIsContentPreferred, aDesiredContentType)
    {
           throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
     },
     isPreferred: function(aContentType, aDesiredContentType)
    {
         try
        {
             var webNavInfo =
             Components.classes["@mozilla.org/webnavigation-info;1"]
                         .getService(Components.interfaces.nsIWebNavigationInfo);
             return webNavInfo.isTypeSupported(aContentType, null);
         }
       catch (e)
       {
             return false;
         }
     },
       GetWeakReference : function()
    {
        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
     }
}

The complete extension can be found here : http://github.com/bitboxer/firefox-detinyfy

A: 

Okay, I did some research. The Hook was a wrong aproach. I changed the code now. Look into the git to find out more...

bitboxer
The github link above is broken, and in any case if you could include a quick summary of the fix that you made, it would be very helpful, so that we don't have to dig through your code to find it.
MatrixFrog
I fixed the link. And if you want to know more, look into : http://github.com/bitboxer/firefox-detinyfy/blob/master/content/overlay.js - especially the override* methods
bitboxer