Back to articles
50 Lines of TypeScript to Automate Any Website with AI

50 Lines of TypeScript to Automate Any Website with AI

via Dev.toIdan Rubin

Most AI browser automation tools fall into two camps: vision-based (screenshot the page, send it to a model, get click coordinates) or selector-based (CSS/XPath targeting). Both have fundamental problems. Vision is slow and expensive — every action requires a screenshot round-trip to a vision model. Selectors are brittle and meaningless to an LLM — div.container > ul > li:nth-child(3) > a tells the AI nothing about what it's clicking. There's a third approach: text snapshots with numbered refs . The browser's accessibility tree is already a structured, semantic representation of the page. Give it to the AI as text, let the AI pick a ref, execute the action. No vision, no selectors, deterministic targeting. Here's a complete AI browser agent using browserclaw and Claude: import Anthropic from " @anthropic-ai/sdk " ; import { BrowserClaw } from " browserclaw " ; const anthropic = new Anthropic (); const SYSTEM = `You are a browser automation agent. You receive a text snapshot of a web pa

Continue reading on Dev.to

Opens in a new tab

Read Full Article
4 views

Related Articles