import asyncio import json import sys import websockets import requests if sys.platform == "win32": try: sys.stdout.reconfigure(encoding='utf-8') except Exception: pass async def inspect_vue_app(): pages = requests.get("http://localhost:9222/json/list").json() ws_url = pages[0]["webSocketDebuggerUrl"] async with websockets.connect(ws_url, max_size=50*1024*1024) as ws: js = """ (() => { const buttons = []; document.querySelectorAll('button, a, [role="button"], [class*="card"], [class*="btn"], div[class*="item"], div[class*="action"], [onclick]').forEach((el, i) => { const rect = el.getBoundingClientRect(); const text = (el.innerText || el.getAttribute('aria-label') || '').trim(); if (rect.width > 20 && rect.height > 15 && text.length > 0) { buttons.push({ idx: i, text: text.slice(0, 50).replace(/\\n/g, ' '), tag: el.tagName, cls: el.className, x: Math.round(rect.left), y: Math.round(rect.top), w: Math.round(rect.width), h: Math.round(rect.height) }); } }); return { url: window.location.href, route: window.location.pathname, buttonsCount: buttons.length, buttons: buttons }; })() """ await ws.send(json.dumps({ "id": 1, "method": "Runtime.evaluate", "params": { "expression": js, "returnByValue": True } })) res = json.loads(await ws.recv()) val = res.get("result", {}).get("result", {}).get("value", {}) print(json.dumps(val, indent=2, ensure_ascii=False)) if __name__ == "__main__": asyncio.run(inspect_vue_app())