Firefox plugin intercepts HTTP requests

When I use a plug-in to intercept http requests and modify the parameters in the POST package, I see that the official document mentions such an object as webRequest.UploadData, but I don’t know how to call it. The official did not give examples, and my purpose is to modify POST The parameters in the request are not the request header. I don’t know whether this object can achieve my purpose. I hope that a friend of kindness can give me an example to modify the POST request parameters. Thank you very much!

webRequest.UploadData is an interface that describes what properties you can use on the object in details.requestBody.raw.

See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest#Parameters, which leads to https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest#details, which tells you about the requestBody.raw property that contains a https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/UploadData

Put together that means:

browser.webRequest.onBeforeRequest.addListener((details) => {
  // Your code should probably check if there even can be a raw body (correct request type, no formData etc.).
  const uploadData = details.responseBody.raw;
  console.log(uploadData.bytes);
}, {}, ['requestBody']);

To modify the request you want a webRequest.BlockingResponse-like object, not a webRequest.UploadData-like object. You craft the BlockingResponse object with the properties required and, as described for the addListener callback, return the object from the callback. You also need to set your listener to blocking and have the permission for webRequestBlocking.