Loading...
Loading...
Capture a spatial hierarchy of rendered DOM elements from any webpage. Injects a pre-built script via playwright-cli that walks the DOM, detects layout grids, extracts backgrounds, prunes invisible nodes, promotes elements rendered outside their DOM parent (overlays, fixed navs, modals), and tags overlay nodes with occlusion metadata. Returns three outputs: LLM-friendly indented text, structured JSON tree, and a nodeMap mapping positional IDs to CSS selectors with background and overlay data. Use before page decomposition, overlay detection, brand extraction, or any workflow that needs structured page analysis. Triggers on: visual tree, capture tree, page structure, page hierarchy, DOM tree, capture visual, page analysis, extract tree.
npx skill4agent add adobe/skills page-treeplaywright-cliplaywright-cliplaywright-cli --helpif [[ -n "${CLAUDE_SKILL_DIR:-}" ]]; then
VT_BUNDLE="${CLAUDE_SKILL_DIR}/scripts/page-tree-bundle.js"
else
VT_BUNDLE="$(find ~/.claude \
-path "*/page-tree/scripts/page-tree-bundle.js" \
-type f 2>/dev/null | head -1)"
fi| Parameter | Default | Description |
|---|---|---|
| 900 | Minimum element width in px. Elements narrower than this are excluded. |
VT_BUNDLEinitScript$(cat)playwright-cli eval() => (EXPR)URL="<target URL>"
MINWIDTH=900 # or caller-specified value
# Build config with initScript — injects bundle before navigation
VT_CONFIG="/tmp/vt-config-$$.json"
echo "{\"browser\":{\"initScript\":[\"$VT_BUNDLE\"]}}" > "$VT_CONFIG"
# Open page (or use existing session) — bundle creates window.__visualTree
playwright-cli --config="$VT_CONFIG" open "$URL"
sleep 2
# Capture — pure expression, no IIFE
VT_RESULT=$(playwright-cli eval \
"JSON.stringify(window.__visualTree.captureVisualTree($MINWIDTH))")
rm -f "$VT_CONFIG"r @0,0 1440x5667
rc1 [3x1] @0,0 1440x83 "Header text..."
rc2 @0,83 1440x5216
rc2c1 [bg:image] @0,83 1440x410 "Hero text..."
...ID [role] [CxR] [bg:type] @x,y wxh "text..."selectorbackground{ type, value, raw, source }overlay{ occluding: [sibling IDs this node covers] }playwright-cli goto <url>