Zero-token browser automation via Playwright scripts with CDP lock management and human-like interaction. Use when: (1) automating any browser-based workflow (publish, login, scrape, fill forms), (2) reducing token cost by converting browser-tool explorations into replayable scripts, (3) avoiding CDP port conflicts between OpenClaw browser and Playwright, (4) needing anti-detection/human-like mouse/keyboard behavior for platforms with bot detection. NOT for: simple URL fetches (use web_fetch ins
humanType(page, sel, text) char-by-char with typos |
| element.click() teleport click | humanClick(page, sel) bezier mouse path + hover |
| Direct page operation after load | humanBrowse(page) simulate reading first |
| nativeSetter.call() DOM injection | humanType() or humanFillContentEditable() |
| Fixed cron schedule | jitterWait(1, 10) random offset |
Exception:setInputFiles() for file uploads is allowed (no human simulation possible), but add random delays before/after.
human-like.js API
Function
Purpose
INLINECODE24
Random wait (ms)
INLINECODE25
Longer pause before form fills |
| humanClick(page, sel) | Bezier mouse move → hover → click with press/release jitter |
| humanType(page, sel, text, opts) | Char-by-char typing, normal distribution speed, 3% typo rate |
| humanFillContentEditable(page, sel, text) | For contenteditable divs (line-by-line Enter + humanType) |
| humanBrowse(page, opts) | Simulate page reading (scroll + mouse wander, 2-5s) |
| humanScroll(page, opts) | Random scroll with occasional reverse |
| jitterWait(minMin, maxMin) | Random delay in minutes for cron tasks |
Script Naming Convention
INLINECODE32 — e.g. publish-deviantart.js, read-inbox.js, INLINECODE35
Example Scripts
Production-tested scripts in scripts/examples/. Copy to your workspace scripts/browser/ and adapt.
Script
Platform
Function
INLINECODE38
DeviantArt
Upload image, fill title/desc/tags, submit
INLINECODE39
小红书 | Publish image note with topic tag association via recommend list |
| publish-pinterest.js | Pinterest | Create pin with title/desc, select board |
| publish-behance.js | Behance | Upload project with title/desc/tags/categories |
| read-proton-latest.js | Proton Mail | Read inbox, output JSON list of emails |
| read-xhs-comments.js | 小红书 | Read notification comments, output JSON with reply button index |
| reply-xhs-comment.js | 小红书 | Reply to a specific comment by index |
Usage pattern:
CODEBLOCK5
All example scripts already use human-like.js for anti-detection.
Cron Integration
CODEBLOCK6
Add jitterWait() at script start to randomize execution time.
Troubleshooting
Problem
Fix
Lock held by PID xxx
INLINECODE47
CDP connection timeout
Ensure acquire was called / Chrome is running |
| Login expired | Use browser tool to re-login, then run script |
| Selector not found | Re-explore with browser tool, update script |
| Script timeout | Increase with --timeout flag |
Environment Variables
Var
Default
Description
INLINECODE50
auto-discover
Override CDP port
INLINECODE51
auto-detect | Chrome binary path |
| HEADLESS | auto | true/false to force headless |