2
我正在开发一个FF插件。我想阻止除特定选项卡中的特定域(用户定义的域)以外的任何域的所有http请求。下面给出的功能很好地完成了这项工作。但问题是它阻止来自所有标签的http请求。如何仅在特定标签中启用以下功能?如何获得与http请求关联的选项卡?如何阻止特定选项卡上的HTTP请求?
function allowOnly(domain)
{
//to block http request
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.addObserver(
{
observe:
function(aSubject, aTopic, aData)
{
if ("http-on-modify-request" == aTopic)
{
var url = aSubject
.QueryInterface(Components.interfaces.nsIHttpChannel)
.originalURI.spec;
if (domain.lastIndexOf(doc.location) != 0) //cancel all http request of other domain & sub domain
{
aSubject.cancel(Components.results.NS_BINDING_SUCCEEDED);
}
}
}
}, "http-on-modify-request", false);
}
再一次...任何hep? – 2011-05-29 11:13:39