I have a firefox extension xpcom component that listens to http-on-modify-request and gets the location of the page making the request:
getLocationOfOriginatingWindow: function (httpChannel) {
try {
var notificationCallbacks;
if (httpChannel.notificationCallbacks) {
notificationCallbacks = httpChannel.notificationCallbacks;
}
else if (httpChannel.loadGroup && httpChannel.loadGroup.notificationCallbacks) {
notificationCallbacks = httpChannel.loadGroup.notificationCallbacks;
}
else {
return null;
}
return notificationCallbacks.getInterface(Components.interfaces.nsIDOMWindow).top.location;
}
catch (e) {
DEBUG("Exception getting Window Location: " + e + "\nChannel URI: " + httpChannel.URI.spec);
return null;
}
},
I would also like to get the page element that made the request (img, script etc.). Is there a way to do the from the httpChannel?