N
N
NooBick2021-08-13 01:37:24
Google Chrome
NooBick, 2021-08-13 01:37:24

How to change FormData?

How to change FormData? I have a request interception, I just have to change a little FormData. But after reading all the Google and Yandex, I did not find anything specific.

chrome.webRequest.onBeforeRequest.addListener(
    function(details) {

        /*let formData = details.requestBody.formData;
        if(formData) {
            Object.keys(formData).forEach(key => {
                formData[key].forEach(value => {
                    if(key.includes("name")) {
                        formData.name = "John";
                        alert(formData)
                    }
                    details.requestBody.formData = formData;
                });
            });
        }*/

        return {cancel: true};

        //await ev(details)
    },
    {urls: ["*://vk.com/al_im.php?*=*a_send"]},
    ["requestBody", "blocking"]
);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nadim Zakirov, 2021-08-13
@zkrvndm

This is done through the content script. Using the content script, inject your code onto the VK and then intercept POST requests through the inserted script, if necessary, change it.
PS I'm just not sure that chrome.webRequest.onBeforeRequest allows you to edit the request body, check the documentation - most likely it doesn't.

A
acwartz, 2021-08-13
@acwartz

No way. Requests cannot be modified.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question