To keep a cookie banner out of a dom-to-image screenshot, identify its actual element in DevTools, then either hide it with temporary CSS or exclude it with the library’s filter callback. Use CSS when the banner is outside the capture root or has a separate backdrop; use filter when it is inside the captured subtree. Restore temporary changes after capture, and remember that hiding a banner changes only the screenshot—it does not record consent.
Choose the right removal method
dom-to-image renders a DOM node and its contents. A consent popup may be a single element, several nodes, or an overlay with a separate backdrop. The page structure and the root you pass to the library determine which approach will work.
| Approach | Works when | Important limitation |
|---|---|---|
| Temporary CSS | You can target the banner, including when it is outside the capture root. | A selector that is too broad can hide page content. A backdrop or body scroll lock may need separate handling. |
filter callback |
The banner is a descendant of the node passed to toPng, toJpeg, or toBlob. |
It cannot remove a banner outside the capture root. Returning false excludes the node and its children. |
| Pseudo-element adjustment | The unwanted visual is generated by a matching element’s ::before or ::after. |
Use a build that supports adjustPseudoElement, such as the documented dom-to-image-more API; this is not the same as filtering a regular element. |
The original dom-to-image README describes the filter callback this way: “Should return true if passed node should be included in the output (excluding node means excluding it’s children as well).” Verify that the library version and API you use support the options in your implementation.
Find the banner and its related elements
-
Open the target page in a browser and use DevTools’ element picker to select the visible consent message.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
In the Elements panel, identify the smallest stable selector that uniquely matches the banner: preferably an ID, a data attribute, or a specific class on its container.
-
Check whether the dimmed backdrop is a different element, often a sibling or a separate fixed-position layer. Add a separate selector for it if it should also disappear.
#1 Best Overall
SalePhilips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
-
Check whether the consent manager has put a scroll-locking class on
bodyor set its inlineoverflowvalue. Hiding the banner alone does not necessarily undo that state. -
Confirm the selectors in the browser console with
document.querySelectorAll('YOUR_SELECTOR'). Make sure the match is the popup, not a container that also holds page content.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Selectors such as #onetrust-consent-sdk, #onetrust-banner-sdk, .qc-cmp2-container, [data-testid="cookie-banner"], .cookie-banner, .cookie-consent, and .gdpr-banner are examples to inspect—not universal selectors. Consent vendors and individual sites can change their markup, so verify each selector on the page being captured.
Hide the banner with reversible CSS
A temporary style rule is usually the most robust option when the banner or backdrop might be outside the capture root. Add the rule immediately before capture, and remove it in a finally block so it does not persist if rendering fails.
async function captureWithoutCookieBanner(root) {
const selectors = [
'#onetrust-consent-sdk',
'#onetrust-banner-sdk',
'.qc-cmp2-container',
'[data-testid="cookie-banner"]',
'.cookie-banner',
'.cookie-consent',
'.gdpr-banner'
];
const style = document.createElement('style');
style.dataset.captureCookieCleanup = 'true';
style.textContent = `${selectors.join(',n')} { display: none !important; }`;
document.head.appendChild(style);
try {
if (document.fonts?.ready) await document.fonts.ready;
return await domtoimage.toPng(root, {
cacheBust: true,
filter: (node) => !selectors.some((selector) =>
node instanceof Element && node.matches(selector)
)
});
} finally {
style.remove();
}
}
Pass a visible DOM element as root, such as document.body or a page-specific content container. Replace the sample selector list with selectors you have actually checked. The style rule removes matching elements from the rendered layout with display: none; unlike making an element transparent, this also removes its box. If the banner is fixed over the page, hiding it typically reveals what is beneath it without changing normal document flow.
The function also uses filter as an extra safeguard for matching nodes within the captured subtree. It is safe to omit that option if the CSS rule is sufficient for your page, or to use the filter alone when its scope is adequate.
Recommended Free Tools
Account for a body scroll lock
If the site becomes unscrollable or the capture shows a layout state left behind by the popup, inspect body and the document root for a consent-related class or inline style. Avoid removing broad classes without knowing what else they control. If your capture code must change an inline style, save its previous value and priority, then restore both in finally.
const oldOverflow = document.body.style.getPropertyValue('overflow');
const oldPriority = document.body.style.getPropertyPriority('overflow');
try {
document.body.style.setProperty('overflow', '');
// Apply your temporary banner CSS and run the capture here.
} finally {
if (oldOverflow) {
document.body.style.setProperty('overflow', oldOverflow, oldPriority);
} else {
document.body.style.removeProperty('overflow');
}
}
This example restores only the inline overflow property. If the consent system uses a class or another property to lock scrolling, preserve and restore that specific state instead of assuming this snippet covers it.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Use the filter callback when the banner is inside the capture root
If the popup is within the element you pass to the capture method, a filter can omit it without adding a stylesheet. The callback must match the element itself; excluding it also excludes its descendants.
const selectors = ['#onetrust-banner-sdk', '.cookie-banner'];
const png = await domtoimage.toPng(document.body, {
filter: (node) => !(
node instanceof Element &&
selectors.some((selector) => node.matches(selector))
)
});
Use the callback’s selector list carefully. If the root is a content element and the consent banner is a sibling elsewhere in the page, the callback never sees that sibling. In that case, capture a containing root or use temporary CSS on the live page.
Free tools Windows power users keep installed
One-click scans. No signup required.
Handle banners drawn with pseudo-elements
Sometimes the visible panel or overlay is created by CSS rather than by a separate DOM node. A regular element filter cannot selectively remove a generated ::before or ::after visual. The dom-to-image-more documentation describes an adjustPseudoElement hook for this case:
const png = await domtoimage.toPng(root, {
adjustPseudoElement: (node, pseudo) => {
if (pseudo === ':before' && node.matches('.cookie-banner')) return false;
return undefined;
}
});
Change the pseudo-element and selector to match what DevTools shows. This option is documented for dom-to-image-more; check your installed package’s documentation before using it with another implementation or version.
Wait for styles, fonts, and images
A correct selector does not guarantee a correct screenshot if the page is still rendering. Wait until the page styles have loaded and the fonts needed by the target content are ready. The example waits for document.fonts.ready; if your page loads content or images asynchronously, wait for the relevant page-specific condition before calling the capture method.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
The dom-to-image-more README also calls out waiting for fonts and stylesheets to load before rendering. If a page uses lazy-loaded images, ensure they have been triggered and loaded before capture; otherwise the result can omit them regardless of banner handling. Keep the capture root visible: hidden nodes or hidden ancestors can prevent the expected rendering.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshoot common failures
-
The dark backdrop remains. Inspect the DOM for a separate overlay node and add its precise selector to the temporary CSS list. The banner and its backdrop need not share a parent or selector.
-
The page remains unscrollable. Look for a consent-related class or an inline
overflow: hiddenonbodyor the document root. Restore only the state your capture code changes; removing the popup does not automatically clear a scroll lock. -
Content disappears along with the banner. Your selector likely targets a wrapper that also contains page content. Use DevTools to move to the smallest node that contains only the popup, then verify the match count before capturing.
-
The banner returns before rendering. A consent manager may reinsert it. Apply a narrowly scoped style immediately before capture and remove the style in
finally. Avoid repeatedly deleting nodes in a loop or with a broad mutation observer.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Fonts or styles look wrong. Wait for
document.fonts.readyand the relevant stylesheet loads before rendering; wait for required images or dynamic content separately. -
The filter has no effect. Confirm the matching node is inside the capture root and that
node.matches(selector)is true for it. A filter cannot exclude a sibling outside the root. -
The capture is blank or unexpected. Confirm the root and its ancestors are visible, and that the correct page state has rendered before calling the library.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
-
A pseudo-element remains. Check whether the graphic comes from
::beforeor::afterand use a supported pseudo-element adjustment hook rather than expecting a normal element filter to remove generated content.Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Keep the change reversible and separate from consent
Removing the banner from an image is a presentation change, not a consent action. Do not describe a hidden banner as accepted, declined, or otherwise recorded. If the page will continue to be used interactively after the screenshot, restore the original UI state. GOV.UK Design System documentation provides an example of a hidden option that hides an entire banner and its messages, illustrating that visibility and the underlying interaction are distinct concerns.
For repeat captures across many sites, keep selectors configurable per site and verify them as site markup changes. Prefer hiding the smallest relevant nodes over permanently removing DOM elements: temporary CSS and cleanup in finally are easier to reverse if a capture errors or the page is reused.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. It can accept consent banners before capture and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Its response identifies the page verdict and billing status in headers, and bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. An MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
Here is a one-request example using cURL; replace the target URL with the page you want to capture and supply your API key:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for request options, including output formats and cleanup controls. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card required.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Frequently Asked Questions
Does hiding the banner mean the visitor accepted cookies?
No. It changes what is rendered in the screenshot; it does not record a consent choice.
Can I use the filter if the cookie banner is outside the element I capture?
No. The filter only evaluates nodes in the captured subtree. Use a containing root or temporary CSS on the page.
Why is the backdrop still visible after filtering the banner?
The backdrop may be a separate DOM element. Inspect it and exclude or hide its own selector.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Quick Recap
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.




