browser-script-patterns

A set of browser-console patterns for running JavaScript scripts on x.com. The scripts run in the page’s DevTools console, not as Node.js programs.

In plain words
What is it for?
Use it when writing scripts that scroll through x.com, collect visible items, and process them over multiple runs.
Why use it?
It provides reusable ways to pause between actions, remember processed items, and continue after page navigation. This helps scripts handle content that loads gradually and reduces overly rapid activity.

Agent

Install

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.

agentmods
npx agentmods add agents/nirholas/xactions/browser-script-patterns
Clone the repo
git clone --depth 1 https://github.com/nirholas/XActions
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 489 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce 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

Measured yesterday against content hash 04b037b8e4aa, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

docs/agents/browser-script-patterns.md · 81 lines

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.

Read the full file on GitHub · 81 lines

Changes

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.

  1. yesterday First seen · 81 lines · 0 tokens per session scan A 04b037b8e4aa

Subscribe to this mod's changes

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.

Related

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.

berrzebb/consensus-loop · 58 tokens

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.…

drobins25/craft · 355 tokens

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).

XuanRanL/loamwright-SEO-Skill · 44 tokens

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.

frootai/frootai · 41 tokens

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…

HirogaKatageri/hirokata · 77 tokens

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.".

DDS-Solutions/AI-TadPole-OS · 40 tokens