osascript-chrome
Installation
SKILL.md
osascript-chrome
Full Chrome automation via AppleScript/JXA + Chrome profile data files. All scripts are Python.
Critical Gotchas (read before writing any Chrome script)
- Minimized windows invisible: Chrome returns 0 windows when minimized. Always verify via System Events first.
- Tab variable reference loss: NEVER store a tab in a variable then execute JS on it. Execute JS inline at the point of match — see
scripts/execute-js-in-tab.pyfor theouter:labeled-break pattern. without activatingis invalid on Chrome's tell block — use System Events focus snap instead.- CDP for headless / Electron: osascript only works with real GUI Chrome. Use CDP (see
reference/08-cdp.md) for headless or Slack/VSCode/Notion. - activeTabIndex is 1-based: Chrome AS dictionary uses 1-based tab indices for the active tab property. Array access (
tabs[ti]) is still 0-based. - SQLite scripts copy-first: chrome-history, chrome-downloads all copy the DB to a tempfile before querying — Chrome locks the file while running.
Tab Control
List all open tabs across all windows (handles minimized via System Events):
uv run scripts/list-tabs.py