搜索了一圈,发现chrome有webrequst和declarativeWebRequest的api可以在发送request之前做点hook。
参照官方栗子写了个测试插件
https://developer.chrome.com/extensions/webRequest#event-onBeforeRequest
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
if(info.method == "POST") {
info['requestBody']['formData']['pwd'] = "Hello"
alert("POSTING:" + JSON.stringify(info.requestBody.formData.pwd))
}
return {redirectUrl: info.url};
},
{urls: ["*://*/*"]},
["blocking", "requestBody"]);
可以看到post的数据,也能修改。 但是尼玛,没有办法把修改后的数据传递出去啊,return类型只有重定向和取消requset!
还能有其他什么方法吗?或者oprea,firefox上可以也行。
参照官方栗子写了个测试插件
https://developer.chrome.com/extensions/webRequest#event-onBeforeRequest
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
if(info.method == "POST") {
info['requestBody']['formData']['pwd'] = "Hello"
alert("POSTING:" + JSON.stringify(info.requestBody.formData.pwd))
}
return {redirectUrl: info.url};
},
{urls: ["*://*/*"]},
["blocking", "requestBody"]);
可以看到post的数据,也能修改。 但是尼玛,没有办法把修改后的数据传递出去啊,return类型只有重定向和取消requset!
还能有其他什么方法吗?或者oprea,firefox上可以也行。
