TamperMonkey: Modify Post Request Data Payload OR Change Response Body

127 views Asked by At

I'm still fairly new to user scripts/Javascript and have been looking for a way modify either the request data payload or change the returned response body of a post request. The site in question performs a XHR POST request (in curl)

curl 'https://somesite.com/endpoint' -X POST -H {various headers} --data-raw 'id=someid'

and usually returns a JSON response (36 character alphanumeric string, made up here) like

dg9gt8hs-ds8g-09ds-9dsf-ad8ygs70dsd0

Sometimes, the response can be a string that is checked against logic in a Javascript function. I've tried putting together a user script in TamperMonkey for this, but I'm not familiar enough with Javascript to get it working.

Ideally, this script would only be triggered for https://somesite.com/endpoint, and then randomly change someid before the POST request is sent OR modify the response body before being passed to the site's functions.

Is this possible with TamperMonkey? Thanks in advance for the help!

0

There are 0 answers