开发者

listening and accessing to all the request made by firefox

I am developing an addon which will modify all the http request made by firefox. So, I want to listen and mod开发者_开发知识库ify all the request url made by browser from different sites. How can I get an access to different http request url and modify them. Is there any event which is fired in firefox before requesting any http-request. So, please suggest anyway to access all the request(ajax as well as document.src) made by browser and modify their url. Thanxs!!


You should take a look at tamperdata sources which is a firefox extension to track and modify http & https requests.


You should register for nsIObserver's "http-on-modify-request" event. This will give you every request just before it is issued by the browser.

var {Cc, Ci} = require("chrome");

var httpRequestObserver =
{
  observe: function(subject, topic, data) 
  {
    if (topic == "http-on-modify-request") {
      var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
      var requestURI = httpChannel.URI.spec;
      // ... 
    }
  }
};

var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
observerService.addObserver(httpRequestObserver, "http-on-modify-request", false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜