Skip to content

Stagehand with Ghostery, block Ads. #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AdamGoodApp opened this issue Feb 28, 2025 · 0 comments
Open

Stagehand with Ghostery, block Ads. #540

AdamGoodApp opened this issue Feb 28, 2025 · 0 comments

Comments

@AdamGoodApp
Copy link

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");

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant