instrumentation
Manage JSVMP source instrumentation: install, log, stop, reload, and check status of script rewrites 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" (default) or "regex". tag: For "install"/"log" — group identifier. rewrite_member_access: For "install" — tap obj[key] reads. rewrite_calls: For "install" — tap fn(args) calls. max_rewrites: For "install" — hard cap on rewrites per file. fallback_on_error: For "install" — auto-fallback to regex if AST fails. 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. filter_property_names: For "install" — only rewrite access to these property names (e.g. ['userAgent', 'platform', 'webdriver']). Dramatically reduces overhead for large files like webmssdk. filter_object_names: For "install" — only rewrite when base object matches (e.g. ['navigator', 'screen', 'document']). 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 |
|---|---|---|---|
| action | Yes | ||
| url_pattern | No | ||
| mode | No | ast | |
| tag | No | vmp | |
| rewrite_member_access | No | ||
| rewrite_calls | No | ||
| max_rewrites | No | ||
| fallback_on_error | No | ||
| ignore_csp | No | ||
| clear_log | No | ||
| wait_until | No | load | |
| tag_filter | No | ||
| type_filter | No | ||
| key_filter | No | ||
| limit | No | ||
| clear | No | ||
| filter_property_names | No | ||
| filter_object_names | No | ||
| max_file_size | No | ||
| on_oversized | No | selective |