实现一个过滤HTTP方法的chrome扩展
我正在尝试实现一个过滤 HTTP 方法的 Google Chrome 扩展。目前我的想法是显示从客户端开始的各种 HTTP 请求,一个接一个。我发现方法 chrome.experimental.webRequest.onBeforeRequest.addListener(interceptRequest, null, ['blocking']);
基本上调用了 InterceptRequest 方法。 InterceptRequest 方法执行以下操作:
function interceptRequest(request) {
console.log('onBeforeRequest ', request.url);
var p = document.createElement("p");
var text = document.createTextNode("" + request.url);
p.appendChild(text);
document.body.appendChild(p);
document.body.append(request.url);
}
基本上它仍然什么也不做,但至少我想打印出 url,开始做一些事情,但这个简单的任务似乎不起作用。
有人知道如何使其发挥作用吗?如果可行,我应该能够从 request
变量中获取 HTTP 方法并结束我的工作。
谢谢
I'm trying to implement a Google Chrome extension that filters HTTP methods. My idea, for now, is just to display all kinds of HTTP requests that starts at the client side, one after the other. I found out the method chrome.experimental.webRequest.onBeforeRequest.addListener(interceptRequest, null, ['blocking']);
which basically calls the interceptRequest method.
The interceptRequest method does the following:
function interceptRequest(request) {
console.log('onBeforeRequest ', request.url);
var p = document.createElement("p");
var text = document.createTextNode("" + request.url);
p.appendChild(text);
document.body.appendChild(p);
document.body.append(request.url);
}
Basically it still does nothing, but at least I would like to print me out the urls, to start doing something, but also this easy task seems not to work.
Does anybody have an idea on how to make that work? If that work, from the request
variable I should be able to get out also the HTTP methods and conclude my work.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可能会混淆 chrome 扩展中存在的各种脚本上下文。
看看这个:http://code.google.com/chrome/extensions /overview.html#arch
I think you may be confusing the various script contexts that exist within a chrome extension.
take a look at this: http://code.google.com/chrome/extensions/overview.html#arch