hook_function
Hook JavaScript functions to intercept or trace execution, enabling dynamic analysis and reverse engineering.
Instructions
Hook or trace a function (v0.9.0 unified).
Replaces hook_function + trace_function.
Args: function_path: Full path like "window.encrypt", "XMLHttpRequest.prototype.open", "JSON.stringify". mode: "intercept" — inject custom JS before/after/replace the function. Requires hook_code. (was: hook_function) "trace" — non-invasive trace logging args, return values, and optionally call stacks. (was: trace_function) hook_code: JS code for "intercept" mode. Context vars: - arguments: original args - __this: the 'this' context - __result: return value (only in position="after") position: For "intercept": "before", "after", or "replace". non_overridable: For "intercept": use Object.defineProperty to lock. persistent: If True, survives page navigation. log_args: For "trace": record arguments (default True). log_return: For "trace": record return values (default True). log_stack: For "trace": record call stacks (default False). max_captures: For "trace": max calls to record (default 50).
Returns: dict with status, target, mode.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| function_path | Yes | ||
| mode | No | intercept | |
| hook_code | No | ||
| position | No | before | |
| non_overridable | No | ||
| persistent | No | ||
| log_args | No | ||
| log_return | No | ||
| log_stack | No | ||
| max_captures | No |