replace-xhr-response
The replace-xhr-response snippet replaces the response of a XHR request if the response text matches a given regular expression pattern.
Parameters
|
Name |
Description |
Mandatory |
Default |
|---|---|---|---|
|
search |
String or regex pattern run against the stringified XHR response. |
Yes |
n.a. |
|
replacement |
Everything that matches the regex will be replaced with this. |
No |
empty string |
|
needle |
Replacement only happens if needle text is present in the response. Enclose in |
No |
empty string |
Filter examples
|
Filter |
Result |
|---|---|
|
|
Removes anything like |
|
|
Replaces the string in the response body. |
|
|
Replaces only if the response contains "example.com". |
Debugging
|
Message |
When |
Definition |
|---|---|---|
|
|
After wrapping XMLHttpRequest |
XHR calls are intercepted. |
|
|
Matching needle found |
We will look for the search parameter next. |
|
|
Needle not found |
Response will not be modified. |
|
|
After replacement |
The response was successfully replaced. |