Ad and content blocking
Block ads, trackers, cookie banners, popups, and overlays from screenshots
Ad and content blocking
Remove unwanted content like ads, trackers, cookie consent banners, marketing popups, and location overlays to capture clean screenshots.
Ad, cookie banner, and popup blocking are enabled by default across capture APIs. Set blockAds: false, blockCookieBanners: false, or blockPopups: false when you need the corresponding page elements preserved.
Quick options
Ad blocking
Common advertising networks are removed by default:
{
"url": "https://example.com"
}This blocks:
- Google Ads
- Facebook Ads
- Amazon Ads
- Common ad networks and exchanges
- Tracking pixels
Cookie banner blocking
GDPR/CCPA cookie consent popups are removed by default:
{
"url": "https://example.com"
}This handles:
- OneTrust
- Cookiebot
- TrustArc
- Custom consent implementations
- EU cookie notices
Popup and overlay blocking
Page-blocking marketing and location interruptions are removed by default:
{
"url": "https://example.com"
}This handles common forms of:
- Newsletter and subscription dialogs
- Promotions and discount offers
- Country, region, language, and currency selectors
- Surveys and app-install prompts
- Notification prompts and age gates
- Delayed modals, dimmed backdrops, and scroll locks
- Dialogs rendered inside open shadow roots
Detection combines interruption-related semantics with modal-like structure and geometry. Inline newsletter sections and ordinary page content are left intact.
Disable blocking
Set an option to false if you want to preserve that content:
{
"url": "https://example.com",
"blockAds": false,
"blockCookieBanners": false,
"blockPopups": false
}See Remove popups and overlays for examples, fallback strategies, and guidance on when to keep dialogs visible.
Block levels
For more comprehensive blocking, use the blockLevel parameter:
{
"url": "https://example.com",
"blockLevel": "pro"
}Available levels
| Level | Description | Use case |
|---|---|---|
none | No domain blocking | Full page render |
light | Basic ad networks | Minimal blocking |
normal | Common trackers and ads | General use |
pro | Aggressive blocking | Clean screenshots |
pro_plus | Very aggressive | Maximum blocking |
ultimate | Most aggressive | May break some sites |
Higher block levels may break some websites that depend on blocked resources. Test your target URLs before using aggressive levels in production.
What gets blocked
Each level includes everything from lower levels plus:
Light
- Major ad networks (Google, Facebook, Amazon)
- Basic analytics (Google Analytics)
Normal
- Social media trackers
- Marketing pixels
- A/B testing platforms
- Session recording tools
Pro
- All third-party tracking
- CDN-hosted trackers
- Fingerprinting scripts
- Most advertising
Pro Plus
- Aggressive list additions
- Regional ad networks
- Crypto miners
- Malware domains
Ultimate
- Everything above
- Edge cases and new trackers
- May over-block legitimate resources
Hide specific elements
For fine-grained control, hide elements by CSS selector:
{
"url": "https://example.com",
"hideSelectors": [
".newsletter-popup",
"#chat-widget",
"[data-testid='promo-banner']",
".sticky-footer-ad"
]
}Selector examples
| Element | Selector |
|---|---|
| Chat widgets | #intercom-container, .drift-widget |
| Newsletter popups | .modal-newsletter, [data-popup='newsletter'] |
| Promo banners | .promo-banner, .announcement-bar |
| Social share buttons | .share-buttons, .social-links |
| Fixed headers | .sticky-header |
You can hide up to 50 selectors per request.
Custom CSS
Inject CSS to hide or modify elements:
{
"url": "https://example.com",
"customCss": ".newsletter-modal { display: none !important; } .hero-section { background: #fff; }"
}Common patterns
Hide multiple elements:
.ad-container, .sponsored-content, .affiliate-link {
display: none !important;
}Remove sticky positioning:
.sticky-header, .fixed-sidebar {
position: relative !important;
}Disable animations:
*, *::before, *::after {
animation: none !important;
transition: none !important;
}Examples
Clean article screenshot
curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/article",
"blockAds": true,
"blockCookieBanners": true,
"blockPopups": true,
"hideSelectors": [
".newsletter-modal",
".related-articles",
".comments-section"
],
"fullPage": true
}' --output clean-article.pngE-commerce product page
curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/product",
"blockLevel": "pro",
"hideSelectors": [
"#chat-widget",
".upsell-section"
],
"customCss": ".price-tag { font-size: 24px !important; }"
}' --output product.pngNews website
curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/news",
"blockAds": true,
"blockCookieBanners": true,
"blockPopups": true,
"blockLevel": "normal",
"customCss": "video { display: none; } .paywall-overlay { display: none !important; }"
}' --output news.pngBest practices
Use the defaults first
Begin with the default blockAds, blockCookieBanners, and blockPopups behavior:
{
"url": "https://example.com"
}Only increase blockLevel if needed.
Test before production
Some sites break with aggressive blocking. Test your target URLs:
const levels = ['none', 'light', 'normal', 'pro'];
for (const level of levels) {
const screenshot = await capture({
url: 'https://example.com',
blockLevel: level,
});
// Verify output visually
}Use selectors for specific elements
If blocking breaks functionality, switch to targeted selectors:
{
"blockLevel": "none",
"hideSelectors": [
".specific-ad-container",
"#that-annoying-popup"
]
}Combine approaches
Layer blocking methods for best results:
{
"blockAds": true,
"blockCookieBanners": true,
"blockPopups": true,
"blockLevel": "light",
"hideSelectors": [".newsletter-modal"],
"customCss": ".chat-widget { visibility: hidden; }"
}