Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
774 views
Welcome To Ask or Share your Answers For Others

1 Answer

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: ["https://myurlhere.com/*"]},
    ['requestBody']
);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...