Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add agents/nirholas/xactions/browser-script-patternsgit clone --depth 1 https://github.com/nirholas/XActionsWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00489 |
| Opus 5 | $0.00000 | $0.00244 |
| Sonnet 5 | $0.00000 | $0.00098 |
| Haiku 4.5 | $0.00000 | $0.00049 |
Grade A, and why
browser-script-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Browser Script Patterns
XActions browser scripts run in DevTools console on x.com. They are NOT Node.js scripts.
Standard IIFE Pattern
(() => {
const $button = '[data-testid="someButton"]';
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
const run = async () => {
// Script logic with await sleep(1000) between actions
};
run();
})();
State Persistence
Scripts stop on page navigation. Use sessionStorage to track progress across re-runs:
const getProcessed = () => {
try { return JSON.parse(sessionStorage.getItem('xactions_key') || '[]'); }
catch { return []; }
};
const markProcessed = (id) => {
const items = getProcessed();
if (!items.includes(id)) {
items.push(id);
sessionStorage.setItem('xactions_key', JSON.stringify(items));
}
};
Rate Limiting
- 1-3 second delays between individual actions (clicks, scrolls)
- 30+ second delays for bulk DMs
- Re-run script if it finishes but items remain (DOM loads in batches)
- X may temporarily restrict actions under heavy automation
Scroll + Collect Pattern
Most scripts scroll the page to load more content, then process visible elements:
const collectAndProcess = async () => {
let retries = 3;
while (retries > 0) {
const items = document.querySelectorAll(selector);
if (items.length === 0) { retries--; await sleep(2000); continue; }
retries = 3;
for (const item of items) {
// process item
await sleep(1000);
}
window.scrollBy(0, 500);
await sleep(2000);
}
};
Confirmation Dialog Pattern
Many actions (unfollow, block, leave community) require a confirmation click:
button.click();
await sleep(500);
const confirm = document.querySelector('[data-testid="confirmationSheetConfirm"]');
if (confirm) confirm.click();
Dependencies
Some scripts in src/automation/ require pasting src/automation/core.js first. The SKILL.md for each script notes this when applicable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 81 lines · 0 tokens per session scan A 04b037b8e4aa
browser-script-patterns is an agent published in the GitHub repository nirholas/XActions (492 stars, last pushed 4d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 489 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
ui-reviewer
Find UI issues that code-level analysis (scout, codemap, dependencygraph) cannot detect. Launches a real browser to check rendering, visual states, interactions, a11y, and runtime errors. Use after FE implementation to catch issues invisible to static analysis.
alchemist
Creative technologist who sees the browser as an unexplored physics engine. Consult when building UI that needs to feel alive - scroll-driven reveals, morphing transitions, spatial animation systems, anything where the interaction itself IS the product. Thinks in weight, tension, and breath before thinking in code.…
audit-geo
Evaluates AI crawler access, llms.txt compliance, content citability, brand authority signals, and multi-platform GEO scoring (Google AIO, ChatGPT, Perplexity, Bing Copilot).
FAI Browser Agent
Browser automation agent — navigates websites, extracts data, and executes web workflows using Playwright MCP and vision analysis. Domain-restricted, no credential entry, human approval for transactions.
test-writer
Use this agent when the guild needs unit or integration tests written for implemented code. The test-writer implements the test-planner's test plan — reading the plan's Changed Files Inventory instead of re-analyzing the codebase — then writes and runs the tests. Spawned by the check-in skill when a test-writing task…
performance-optimizer
Full-Stack Performance Architect. Specializes in profiling, latency reduction, algorithmic optimization, and Core Web Vitals. Operates on the principle of "Evidence over Intuition.".