2011-07-10 99 views
0

我需要扩展firebug以使用从网页中提取的链接(当从页面中的任何链接下载时发送)将其发送到将要下载它的另一台机器。我打算使用萤火虫为我提取这个链接。如果有任何其他的方式,我可以从浏览器中获取这些信息,即使是这样,我们将不胜感激。如何为Firebug创建扩展

+0

您正在寻找的下载管理行为的自定义类型。我没有看到Firebug与它有什么关系。 –

+0

您可能会使用Firebug来帮助开发扩展程序,但这听起来不像是需要扩展萤火虫的东西。您可能想要完整扩展或使用GreaseMonkey。 – joshhendo

+0

如果不是萤火虫,那么当用户点击一个链接进行下载时,有没有办法检测到下载从何处开始的链接。 – SThomas

回答

0

实际上,它的坏主意使用事件来检测HTTP请求等功能,Firefox的强大功能xul语言使您能够检测所有浏览器请求/响应,然后您可以决定从请求/响应标题:
你可以使用“http-observe”巫婆其实Firebug用于网络面板
- 这里是mozilla MDN中的“http-observe”的链接[https://developer.mozilla.org/en/ Setting_HTTP_request_headers] [1]
- 这里也为一个简单的例子 “HTTP-观察”

// first create observerService component as a property into your extension javascript object 
    var myExtension = { observerService:Components.classes["@mozilla.org/observerservice;1"].getService(Components.interfaces.nsIObserverService), 
     init:function(){ 
      // in the init function setup the observe service and set witch javascript object is the listener for http response for example "this" 
      this.observerService.addObserver(this,"http-on-examine-response", false); 
      this.observerService.addObserver(this,"http-on-examine-cached-response", false); 
     }, 
     observe: function(aSubject, aTopic, aData){ // the observe function 
      if (aTopic == "http-on-examine-response" || aTopic == "http-on-examine-cached-response"){ 
       var httpChannel = aSubject.QueryInterface(Components.interfaces.nsIHttpChannel); 
       var URI = httpChannel.originalURI.spec;      
       if (aSubject.loadFlags & httpChannel.LOAD_INITIAL_DOCUMENT_URI){ // this detect if the response is primery request 
        var contentType = httpChannel.getResponseHeader("content-type"); // check the heder content-type 
        if (contentType == "what ever you want"){ // you can check if it zip/html/xml ...etc 
       //do what ever you want 
       } 
       } 
      } 
     } 
    }