Skip to content

Stagehand with Ghostery, block Ads. #540

Closed as not planned
Closed as not planned
@AdamGoodApp

Description

@AdamGoodApp

I can't seem to block any Ads using Stagehand and Ghostery playwright. I'm able to block Ads successfully using puppeteer with the same setup.

import { Page, BrowserContext, Stagehand } from "@browserbasehq/stagehand";
import { PlaywrightBlocker } from '@ghostery/adblocker-playwright';
import fetch from 'cross-fetch';
import dotenv from "dotenv";

dotenv.config();

export async function main({
  page,
  context,
  stagehand,
}: {
  page: Page; // Playwright Page with act, extract, and observe methods
  context: BrowserContext; // Playwright BrowserContext
  stagehand: Stagehand; // Stagehand instance
}) {

  const blocker = await PlaywrightBlocker.fromLists(fetch, [
    'https://easylist.to/easylist/easylist.txt',
    'https://raw.githubusercontent.com/uBlockOrigin/uAssets/refs/heads/master/filters/annoyances-others.txt',
    'https://raw.githubusercontent.com/uBlockOrigin/uAssets/refs/heads/master/filters/filters-2025.txt',
  ]);

  await blocker.enableBlockingInPage(page);
  await page.goto("https://www.cineby.app/movie/1064213");

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions