Learn how to block ads and trackers in your browser sessions
Hyperbrowser’s browser instances can automatically block ads and trackers. This improves page load times and reduces detection risk. You can also block trackers and other annoyances like cookie notices.
Set the appropriate options when creating a session:
Copy
Ask AI
import { Hyperbrowser } from "@hyperbrowser/sdk";import { config } from "dotenv";config();const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY,});async function main() { const session = await client.sessions.create({ adblock: true, trackers: true, annoyances: true, // You must have trackers set to true to enable blocking annoyances and adblock set to true to enable blocking trackers. }); try { console.log("Session Live URL:", session.liveUrl); console.log("WS Endpoint:", session.wsEndpoint); // ... connect with Playwright/Puppeteer and automate } finally { await client.sessions.stop(session.id); }}main().catch(console.error);
Some site prompt users for cookies in a particularly intrusive way for scraping. If the acceptCookies param is set, then Hyperbrowser will automatically accept cookies on the browsers behalf.