我知道 chrome.webRequest.onBeforeRequest 允许拦截,分析和阻止请求,但它只允许访问请求头,而不是请求机构(据我所知)。
示例用例:想想拦截表单值。
看起来有一个API更改提议这里暗示这一点。
有没有另一种方法可以完成?
感谢。
解决方案此功能已添加到API现在,请参阅文档。
为了访问主体,您需要执行以下操作:
chrome.webRequest.onBeforeRequest.addListener(函数(详情) { console.log(details.requestBody); }, {url:[myurlhere/*]}, ['requestBody'] );
I'm aware that chrome.webRequest.onBeforeRequest allows a request to be intercepted, analyzed and blocked, but it only allows access to the request headers, and not the request body (as far as i know).
Sample use case: think intercepting form values.
It seems there is a API change proposal here suggesting exactly this.
Is there another way this could be accomplished?
Thanks.
解决方案This functionality has been added to the API now, see the documentation.
In order to access the body you need to do the following:
chrome.webRequest.onBeforeRequest.addListener( function(details) { console.log(details.requestBody); }, {urls: ["myurlhere/*"]}, ['requestBody'] );
更多推荐
拦截来自chrome扩展的HTTP请求体
发布评论