cdp_find_route.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. """Find the game-detail URL format: click the 柠檬复古76 card title (known
  2. position from recon) and read the resulting URL, or find router info.
  3. Safer: check the Vue router's route table for the game-detail path pattern.
  4. """
  5. import asyncio
  6. import json
  7. import sys
  8. import httpx
  9. import websockets
  10. async def main():
  11. async with httpx.AsyncClient(timeout=5) as c:
  12. r = await c.get("http://127.0.0.1:9222/json/list")
  13. home = next((t for t in r.json() if "homePage" in t.get("url", "")), None)
  14. if not home:
  15. print("no home")
  16. return 1
  17. async with websockets.connect(home["webSocketDebuggerUrl"], max_size=10**7) as ws:
  18. mid = 0
  19. async def ev(expr):
  20. nonlocal mid
  21. mid += 1
  22. await ws.send(json.dumps({"id": mid, "method": "Runtime.evaluate",
  23. "params": {"expression": expr, "returnByValue": True}}))
  24. while True:
  25. m = json.loads(await ws.recv())
  26. if m.get("id") == mid:
  27. return m.get("result", {}).get("result", {}).get("value")
  28. # 1. How does clicking a card work? Inspect the first card's DOM tree
  29. card = await ev(r"""
  30. (function() {
  31. // the 柠檬复古76 card title was at ~(898, 440) region; find clickable ancestors
  32. const els = document.elementsFromPoint(898, 440);
  33. const out = [];
  34. for (const el of els.slice(0, 8)) {
  35. out.push({
  36. tag: el.tagName,
  37. cls: (el.className || '').toString().slice(0, 50),
  38. href: (el.getAttribute && el.getAttribute('href')) || '',
  39. onclick: !!el.onclick,
  40. text: (el.innerText || '').split('\n')[0].slice(0, 30)
  41. });
  42. }
  43. return JSON.stringify(out, null, 1);
  44. })()
  45. """)
  46. print("=== elementsFromPoint(898,440) — the 柠檬 card ===")
  47. print(card)
  48. # 2. Vue router present? Get its routes
  49. routes = await ev(r"""
  50. (function() {
  51. const app = document.querySelector('#app');
  52. if (app && app.__vue_app__) {
  53. const r = app.__vue_app__.config.globalProperties.$router;
  54. if (r) {
  55. return JSON.stringify(r.getRoutes().map(rt => ({path: rt.path.slice(0, 60), name: rt.name})).slice(0, 25));
  56. }
  57. }
  58. if (app && app.__vue__) {
  59. const r = app.__vue__.$router;
  60. if (r) return JSON.stringify(r.options.routes.map(rt => ({path: rt.path.slice(0, 60)})));
  61. }
  62. return 'no router found';
  63. })()
  64. """)
  65. print("\n=== vue routes ===")
  66. print(routes)
  67. # 3. Fallback: known 996box game page URL patterns — check history API
  68. hist = await ev("""
  69. JSON.stringify((window.performance && performance.getEntriesByType('navigation').map(n => n.name)) || [])
  70. """)
  71. print(f"\nnav entries: {hist}")
  72. return 0
  73. sys.exit(asyncio.run(main()))