Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Hide a Cookie Banner in Website Screenshots Without Accepting Tracking

Hide a verified cookie banner with Playwright CSS at screenshot time—without clicking Accept or storing a consent choice. A hidden banner does not block or verify tracking.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To remove a cookie banner from a screenshot without accepting tracking, hide the specific banner with CSS at screenshot time. Do not click “Accept” or preload a consent cookie. This changes the image, not the site’s consent state: the page may still send tracking requests, and the screenshot cannot prove otherwise.

Hide the banner only for the screenshot

With Playwright, inspect the target page to identify its actual banner container, then pass a narrowly scoped CSS rule through the screenshot API’s style option. Replace the example selector below with one verified on the page you are capturing:

await page.screenshot({
  path: 'page.png',
  style: '.REPLACE_WITH_VERIFIED_BANNER_SELECTOR { display: none !important; }'
});

The rule is applied for the screenshot; it does not click a consent control or record a consent decision. Check the rendered result to ensure the selector hides only the banner and leaves the rest of the page intact. Site markup varies, so there is no universal selector.

Use a clean browser context and avoid consent actions

  1. Create an isolated, non-persistent Playwright browser context. This prevents the capture from inheriting cookies and other stored state from an earlier browser session. Playwright documents isolated contexts and methods for inspecting or clearing cookies in its BrowserContext documentation.
  2. Load the page without accepting or preloading consent. Do not click an accept button or insert a saved consent cookie just to clear the image. The page’s own scripts may still make network requests.
  3. Inspect the page and verify the banner selector. Choose the narrowest selector that identifies the banner on the target site, then apply it using the screenshot code above.
  4. Review the screenshot. Confirm the intended content remains visible and only the banner was hidden.

Playwright’s Page screenshot documentation describes the screenshot style option. Its addInitScript mechanism is separate: the documentation says that script is evaluated after the document is created but before its scripts run. That wording is not a claim that screenshot CSS blocks scripts or prevents tracking.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know what each approach changes

Approach What it changes When it fits Important limitation
Capture-time CSS Screenshot presentation You need a clean visual image without making a consent choice Does not make or verify a consent decision; the selector is site-specific.
Use the site’s reject or preferences control The site’s consent interaction or state You need to test or exercise the consent controls This is a consent interaction, not screenshot-only cleanup.
Use the site’s accept control The site’s acceptance interaction or state Testing acceptance behavior It conflicts with the goal of not accepting tracking.

For example, Browserless’s cookie-consent example clicks an accept-like selector before taking a screenshot. That is not the right workflow when you want to avoid accepting tracking.

As an Amazon Associate I earn from qualifying purchases.

A hidden banner does not establish privacy or consent

  • CSS hiding only changes what appears in the captured image. It does not mean consent was rejected, stored, or respected.
  • A clean screenshot does not show whether cookies, pixels, or other tracking requests ran. Inspect or control browser storage and network activity separately if you need to investigate them; the screenshot technique alone is not a tracking audit.
  • Use this method only for pages you are authorized to view. Whether a particular site’s interface or capture workflow meets a legal obligation depends on the site and jurisdiction; this visual technique does not answer that question.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. Its clean-shot workflow accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. This is a different workflow from applying a CSS rule without making a consent choice, so use the DIY method above if you specifically require capture-only hiding without accepting or recording consent.

For a one-call capture, see the ScreenshotNeo API documentation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo bills only clean shots: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.

The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month with no card.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.