extract_script
Extract a JavaScript string from a captured response body or JSON path and optionally save it to a file, enabling patching of inline SDK code that lacks a script resource.
Instructions
Pull a script string out of a captured response and (optionally) save it.
Use this for SDK code that reaches the page through fetch + eval
instead of a <script src> tag: such code has no script resource, so
source search cannot see it and route rewriting cannot reach it. Extract it
here, patch it locally, then serve the patched file back with
intercept_request(action="mock", mock_response={"body_file": ...}).
Args:
request_id: Captured request to read response_body from. Requires the
body to have been captured (network_capture(capture_body=True)).
body: Raw response text to use instead of a captured request (mutually
exclusive with request_id).
json_path: Dotted/bracketed JSON path to the script string, e.g. data.data
or items[0].script. Pass an empty string when the body itself is
the script.
output_file: Write the extracted script here (UTF-8, regular file only).
overwrite: Allow replacing an existing output_file.
allow_partial: Allow extracting from a response body truncated by
network_capture(max_body_size=...) (default False).
preview_chars: Preview length in the response (never the whole script).
max_inline_chars: Refuse to inline a script larger than this; ask for
output_file instead.
Returns:
dict with chars, sha256, preview, partial, and, when written,
output = {path, bytes, sha256, encoding, chars}.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "extract_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | ||
| json_path | No | data.data | |
| overwrite | No | ||
| request_id | No | ||
| output_file | No | ||
| allow_partial | No | ||
| preview_chars | No | ||
| max_inline_chars | No |