【问题标题】:Modify HTTP Request value in Chrome automatically自动修改 Chrome 中的 HTTP 请求值
【发布时间】:2017-05-18 09:02:29
【问题描述】:

有没有办法或应用程序始终将 POST 请求的值更改为 Chrome 中的特定 URL?

【问题讨论】:

  • 从 chrome 商店尝试 modheader 扩展

标签: google-chrome google-chrome-extension google-chrome-app


【解决方案1】:

试试chrome.webRequest。具体来说,chrome.webRequest.onBeforeRequest.addListener

您将提供字符串 ["blocking"] 作为opt_extraInfoSpec 参数的属性,并提供BlockingResponse 类型的对象作为返回值,该对象指定您要对请求进行哪些更改。 另外,要获取POST请求的正文,opt_extraInfoSpec还需要包含字符串"requestBody"

您的代码将如下所示:

chrome.webRequest.onBeforeRequest.addListener( function(details){
//
    if(details.method == "POST")
        var new_url = "http://stackoverflow.com/my_new_url";

    return {redirectUrl:  new_url}; 

}, ({urls: ["http://*/*", "https://*/*"] }), ["blocking", "requestBody"]);

文档https://developer.chrome.com/extensions/webRequest

编辑:您将只放置在后台页面中的代码。

【讨论】:

    猜你喜欢
    • 2015-03-03
    • 1970-01-01
    • 2014-05-20
    • 2011-03-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    • 2017-02-08
    相关资源
    最近更新 更多