instrumentation
Instrument JavaScript code with JSVMP to trace and log runtime behavior, supporting install, log, stop, reload, and status actions for reverse engineering.
Instructions
JSVMP source-level instrumentation (v0.9.0 unified).
Replaces instrument_jsvmp_source / get_instrumentation_log / stop_instrumentation / reload_with_hooks.
Args: action: "install" — register route + AST/regex rewrite on matched scripts. Requires url_pattern. (was: instrument_jsvmp_source) "log" — fetch accumulated tap events from instrumented code. (was: get_instrumentation_log) "stop" — unregister instrumentation route. (was: stop_instrumentation) "reload" — reload page so persistent hooks fire before page JS. (was: reload_with_hooks) "status" — show active instrumentations and stats. (was: get_instrumentation_status) url_pattern: For "install"/"stop" — glob pattern matching VMP script URLs. mode: For "install" — "ast" (esprima then local bundled Acorn) or "regex" (conservative whole-program subset; unsupported input skipped). tag: For "install"/"log" — group identifier. rewrite_member_access: For "install" — tap obj[key] reads. rewrite_calls: For "install" — tap fn(args) calls. include_source_site: For "install" — attach a stable site_id and monotonic seq to tap events, plus an original-source range map in the log response. Default False. max_rewrites: For "install" — hard cap on rewrites per file. fallback_on_error: For "install" — try conservative regex on AST failure only without property/object filters; otherwise pass through unchanged. ignore_csp: For "install" — skip CSP pre-flight check. clear_log: For "reload" — clear JSVMP logs before reload. wait_until: For "reload" — "load" / "domcontentloaded" / "networkidle". tag_filter: For "log" — filter by tag. type_filter: For "log" — "tap_get", "tap_call", "tap_method", "tap_call_err". key_filter: For "log" — substring match on property/method name. limit: For "log" — max entries to return. clear: For "log" — clear log after retrieval in the selected main world. frame_url: For log; select a target frame by URL pattern. frame_name: For log; select a target frame by name. frame_index: For log; current frame snapshot index, not a persistent identity. Source scripts run in the main world; logs are always read there. filter_property_names: For AST "install" — only rewrite reads/methods of these property names (e.g. ['userAgent', 'platform', 'webdriver']). Dramatically reduces overhead for large files like webmssdk. filter_object_names: For AST "install" — only rewrite when the static base object path matches (e.g. ['navigator', 'this.bytecode']). Dynamic object identity is not inferred. Regex mode rejects nonempty filters. max_file_size: For "install" — files larger than this (bytes) trigger on_oversized behavior. Default 200KB. on_oversized: For "install" — "selective" (require filters), "skip", or "force" (full rewrite anyway). Default "selective".
Returns: dict with action-specific results.
IMPORTANT — timing for sync-loaded scripts (e.g. webmssdk): Route interception only catches requests made AFTER the route is registered. For scripts loaded via during page load, you MUST call instrumentation(action='install') BEFORE navigate(). Pattern: 1. launch_browser() 2. instrumentation(action='install', url_pattern='**/webmssdk*') 3. navigate("https://www.douyin.com/...") If called after navigate, use instrumentation(action='reload') to re-trigger page load with routes active.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No | vmp | |
| mode | No | ast | |
| clear | No | ||
| limit | No | ||
| action | Yes | ||
| clear_log | No | ||
| frame_url | No | ||
| frame_name | No | ||
| ignore_csp | No | ||
| key_filter | No | ||
| tag_filter | No | ||
| wait_until | No | load | |
| frame_index | No | ||
| type_filter | No | ||
| url_pattern | No | ||
| max_rewrites | No | ||
| on_oversized | No | selective | |
| max_file_size | No | ||
| rewrite_calls | No | ||
| fallback_on_error | No | ||
| filter_object_names | No | ||
| include_source_site | No | ||
| filter_property_names | No | ||
| rewrite_member_access | No |