Why Cookie Banners Ruin Screenshots (And How to Fix It)
Cookie banners wreck automated screenshots and OG images. Here's how a screenshot API that removes cookie banners fixes it in one GET request.
If you've ever automated screenshots of live websites, you've run into this: the page loads, the renderer fires, and right in the middle of your clean capture sits a giant GDPR consent modal asking someone to "Accept All Cookies." It's ugly, it's inconsistent across regions, and it breaks every visual monitoring dashboard, OG image generator, and PDF export pipeline that depends on predictable output.
This isn't a rare edge case. Most EU-facing sites, and a growing number of US ones under CCPA, inject a consent layer before anything else renders. If your screenshot tool just loads the page and snaps a pixel grid, you're capturing that banner every single time.
Why Cookie Banners Are a Specific Problem for Automated Screenshots
Manual screenshots are easy to fix: you click "Accept," then take the shot. Automation doesn't have that luxury. A few reasons this gets messy fast:
- Banners are inconsistent. OneTrust, Cookiebot, Osano, and dozens of custom-built consent tools all render differently, with different selectors, different dismiss buttons, and different load timing.
- They're often injected late. Many consent scripts fire 500ms to 2 seconds after initial page load, so a naive "wait for DOMContentLoaded then screenshot" approach still catches them mid-animation or fully rendered.
- They cover critical UI. Pricing pages, hero sections, and nav bars are exactly where these modals sit, so they block the parts of the page you actually wanted to capture for an OG image or a visual regression test.
- They vary by geography. If your screenshot service routes through different regions, the same URL might render with a GDPR banner in one run and nothing in another, making your output non-deterministic.
The DIY Approaches (and Why They're Fragile)
If you're running your own headless Chrome via Puppeteer or Playwright, there are a few common workarounds. None of them hold up well at scale.
1. Hardcoded CSS selector hiding
You maintain a list of known cookie banner selectors (#onetrust-consent-sdk, .cookiebot-banner, etc.) and inject CSS to hide them before the screenshot:
await page.addStyleTag({
content: '#onetrust-consent-sdk, .cc-window { display: none !important; }'
});
This works until a site changes its consent provider or a new one appears that's not on your list. You end up with a growing, never-complete blocklist that needs constant maintenance.
2. Auto-clicking "Accept" buttons
Some teams try to detect and click accept buttons programmatically. The problem: button text and structure vary wildly ("Accept All," "I Agree," "OK, Got It," localized text in dozens of languages), and clicking "accept" also changes the actual state of the page, which may not reflect what a real first-time visitor sees.
3. Waiting longer and hoping
Adding arbitrary setTimeout delays sometimes lets you dismiss banners manually before the real screenshot event, but this slows down every single request and still fails on banners that re-appear or animate in late.
None of these scale cleanly across hundreds of client domains or thousands of daily captures. That's the exact problem a screenshot API that removes cookie banners automatically is built to solve.
What Automatic Cookie Banner Removal Actually Looks Like
A properly built screenshot API handles this at the rendering layer, before the image is ever generated. With pxshot, cookie banners are stripped automatically on every request, no flags, no configuration, no per-domain rules to maintain. You send a URL, pxshot renders it in real Chrome, detects and removes consent overlays, and returns a clean PNG, JPEG, WebP, or PDF.
Here's what that looks like in practice:
GET https://pxshot.dev/api/screenshot?url=https://example.com&format=png
One GET request. No browser management, no selector maintenance, no retry logic for flaky consent scripts. The response is the page as a user would see it after dismissing the banner, not as it looks mid-popup.
Why This Matters for Specific Use Cases
- OG image generation: If you're dynamically generating social preview images from live pages, a cookie banner in the preview looks broken and unprofessional in a Twitter or Slack unfurl.
- Visual regression monitoring: If your diffing tool flags changes every time a cookie consent script updates its banner styling, you get false positives that drown out real visual bugs.
- PDF generation: Reports, invoices, or archived page snapshots exported as PDFs look unfinished with a gray overlay baked into the top of the document.
- Link previews: Any tool that shows a thumbnail of a linked URL (chat apps, bookmarking tools, CRM integrations) needs the actual content, not a consent wall.
Checklist: Evaluating a Screenshot API for Cookie Banner Handling
If you're comparing screenshot services, here's what to actually test before committing:
- Test against real consent providers. Run requests against sites using OneTrust, Cookiebot, Osano, and a custom in-house banner. Check if all of them get stripped, not just the most common one.
- Check timing-sensitive banners. Some consent scripts load after a delay. Confirm the API waits for network idle or a reasonable render delay, not just the initial DOM load.
- Verify it doesn't break the rest of the layout. Removing a banner via brute-force CSS can sometimes leave behind empty space or broken z-index stacking. Check the final image looks natural.
- Confirm consistent results across regions. If you're capturing the same URL repeatedly, the output should be identical regardless of which banner variant a geo-routed request happens to trigger.
- Look for zero-config behavior. You shouldn't need to pass a flag or maintain a selector list per domain. This should be the default behavior, not an opt-in feature.
A Quick Real-World Example
Say you're building a changelog or directory site that shows live thumbnails of customer websites. Without banner removal, half your thumbnails show a gray overlay with "We use cookies to improve your experience." It looks like your directory is broken, even though the issue is entirely on the source site's side.
Swapping in a screenshot API that handles this automatically fixes every thumbnail at once, retroactively, without touching a single line of per-site logic:
GET https://pxshot.dev/api/screenshot?url=https://customer-site.com&format=webp&width=1200&height=630
That single request returns a clean, banner-free 1200x630 image ready to drop straight into an OG tag or a thumbnail grid.
Try it without even signing up: there's a live demo on the pxshot.dev homepage where you can paste any URL and see the cleaned-up screenshot instantly. If it fits your workflow, the free plan includes 50 screenshots a month, enough to test it against your real target sites before committing to anything.