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
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
精彩评论