Skip to content

Brainrot-Creations/agent-block

Repository files navigation

agent-block

Ghost AI agents from your site.


AI agents (browser-use, agent-browser, Operator, Playwright, Puppeteer) read your site through the browser's accessibility tree. agent-block makes that tree useless — scrambled labels, honeypot traps, physics-based human detection, and visual decoys that make agents interact with fakes.


Install

npm install agent-block
import { block } from 'agent-block';
block();

Done.


Setup

Next.js

npm install @brainrotcreations/agent-block-next
// app/layout.tsx
import { AgentBlockScript } from '@brainrotcreations/agent-block-next';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <AgentBlockScript />
      </body>
    </html>
  );
}
Pages Router
// pages/_app.tsx
import { AgentBlockScript } from '@brainrotcreations/agent-block-next';
import type { AppProps } from 'next/app';

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Component {...pageProps} />
      <AgentBlockScript />
    </>
  );
}

React (Vite)

npm install agent-block
// src/main.tsx
import { block } from 'agent-block';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';

block();  // before createRoot

createRoot(document.getElementById('root')!).render(<App />);

Plain HTML

<head>
  <script src="https://unpkg.com/agent-block/dist/index.global.js"></script>
  <script>AgentBlock.block();</script>
</head>

How it works

Layer What it does
Detect 20+ signals across 3 tiers — automation globals, browser anomalies, behavioral physics
Honeypots Mirror overlays sit on top of every real button. Agents see decoys, humans see the real thing
Inert gate Protected elements are removed from the AX tree entirely until a real user is confirmed
Text obfuscation Unicode homoglyphs replace readable characters — visually identical for humans, gibberish for bots
Rotate ARIA labels rotate on a timer — agents always get stale names
Noise 200 fake AX elements flood the tree with decoys
Poison Prompt-injection strings and fake nav traps target LLM context windows
Screenshot block Overlay destroys agent screenshots on high-confidence detection
Print / PDF block Hides real content in @media print, shows a branded decoy
ID scramble Form input IDs rotated at session start — getElementById('inp-email') returns null

Log detections

block({
  onDetected: (result) => {
    // result.score   — 0–10
    // result.signals — which signals fired
    fetch('/api/bot-detected', {
      method: 'POST',
      body: JSON.stringify(result),
    });
  },
  onHoneypotTriggered: (event) => {
    fetch('/api/honeypot', { method: 'POST', body: JSON.stringify(event) });
  },
});

Config

All options optional. block() with no args uses safe defaults.

block({
  key: 'my-app-secret',         // seeds all scrambling — omit for random per session
  threshold: 5,                 // bot score 0–10 to trigger disruption. Default: 5
  disruption: 'full',           // 'none' | 'noise' | 'rotate' | 'full'. Default: 'full'
  noiseCount: 200,              // fake AX elements. Default: 200
  rotationIntervalMs: 4000,     // label rotation speed. Default: 4000
  honeypots: true,              // mirror honeypot overlays. Default: true
  blockScreenshots: true,       // destroy agent screenshots. Default: true
  poisonAXTree: true,           // inject prompt-injection strings. Default: true
  blockPrint: true,             // hide content in print/PDF. Default: true
  inertGating: true,            // remove elements from AX tree until human confirmed. Default: true
});

Packages

Package Use when
agent-block Vanilla JS, React (Vite/CRA), anything
@brainrotcreations/agent-block Same, scoped alias
@brainrotcreations/agent-block-react React provider + useAgentBlock hook
@brainrotcreations/agent-block-next Next.js — handles SSR edge cases automatically

MIT License · Brainrot Creations · contact@brainrotcreations.com