How to Exclude Ads and Cookie Banners When Saving with SingleFile
Remove ads and cookie banners from a SingleFile save with its annotation editor or CSS selectors, then check the archived page for missing content.
To exclude ads or cookie banners from a SingleFile save, use Annotate and save the page… in the extension’s context menu to remove items from one page, or configure HTML content > remove specific elements with CSS selectors for recurring elements. Check the saved HTML afterward: a selector can remove article content along with the unwanted element.
SingleFile packages a web page and its resources into one HTML file. Its removal controls work on page elements; they do not automatically identify every ad or consent banner on every site. SingleFile’s project documentation describes the extension and its annotation workflow.
Remove an ad or banner from one saved page
- Open the page and let its content finish loading. If a consent banner is present, dismiss it normally if you want the page to reflect that choice before saving.
- Open SingleFile’s extension context menu and choose Annotate and save the page….
- In the annotation editor, select the ad, banner, or other unwanted element and remove it. The editor also supports highlighting and notes.
- Save the page, open the resulting HTML file, and verify that the unwanted element is gone and the content you need remains.
This method is convenient for a one-off cleanup or when the page’s layout makes a stable selector hard to identify. Review the saved copy carefully: removing a large container may also remove an article, navigation, or controls nested inside it.
Remove recurring elements with CSS selectors
When the same unwanted elements appear across pages, configure SingleFile’s HTML content > remove specific elements option. Enter CSS selectors separated by commas. For example, if inspection of a particular site shows that its banner uses #consent-banner and its ad container uses .sidebar-ad, the selector value would be:
#consent-banner, .sidebar-ad
Those selectors are illustrative only; they are not universal selectors and are not supplied as a guaranteed list by SingleFile. Identify the selectors on the site you are saving, then test them on a page where you can verify the result. A site redesign can change its markup or class names, so revisit the selectors if removal stops working or starts removing too much.
- Inspect the page’s HTML in your browser’s developer tools and identify the smallest element that contains only the ad or banner you want removed.
- Add its selector to the specific-element removal option. Separate multiple selectors with commas.
- Save a representative page and inspect the resulting HTML file.
- Adjust or remove any selector that hides content you want to keep.
Prefer a selector for the narrow unwanted element rather than a broad parent container. CSS selector behavior depends on the page’s markup; no single ad or consent selector works everywhere.
Element removal is different from blocking scripts
Do not use script blocking as a substitute for removing an ad or cookie-banner element. SingleFile blocks scripts by default because scripts can change how a page renders and may not work in an offline copy. Its FAQ notes that some interactive elements need JavaScript and can be kept by changing the blocked-resources setting, with other relevant options adjusted as needed. Script blocking changes page behavior; the specific-element option removes matching HTML elements.
If a saved page loses an interactive control, review the blocked-resources configuration separately from your element-removal selectors. Retaining scripts may affect the saved page’s behavior, so check the result against what you need from the archive. See the SingleFile FAQ for its documented settings and limitations.
What to check in the saved HTML
- The target is gone: confirm the ad or consent banner does not appear in the saved copy.
- Article content remains: check the headline, body, images, and any sections you need.
- Links and controls are usable as expected: a saved archive may not behave like the live site, especially when scripts or other resources are blocked.
- The file opens locally: test the saved HTML in your browser rather than relying only on the save confirmation.
Browser security restrictions can also prevent extensions from accessing or modifying some protected pages. If SingleFile cannot capture a page using the normal workflow, the limitation may come from the browser or page permissions rather than a bad selector. The project repository documents the extension’s purpose and constraints.
Or skip the browser setup
If your goal is a screenshot rather than a self-contained HTML archive, ScreenshotNeo can capture a URL with one API call. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before the capture; each cleanup step can be turned off. Bot checks, blank pages, and failed loads are never billed, and the response headers identify the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf.
See the ScreenshotNeo API documentation for request options. This cURL example saves a WebP screenshot:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same endpoint can be called from Python:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
Or from Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
const image = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', image));
ScreenshotNeo offers 1,000 screenshots a month free with no card. Paid plans start at $5 for 3,000 screenshots; yearly billing gives two months free, and every feature is on every plan. Visit ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.
Troubleshooting
| Problem | Likely cause | What to do |
|---|---|---|
| The ad or banner is still in the saved file. | The selector does not match the current page markup, or the element appeared after the page was saved. | Check the element’s current selector, confirm the page is loaded before saving, and try the annotation editor for a one-off removal. |
| Part of the article disappeared. | A selector matched a parent element that also contains wanted content. | Use a narrower selector and save a test copy to inspect the result. |
| A site redesign broke the selector. | The site changed its element IDs, classes, or structure. | Inspect the current markup and update the comma-separated selector list. |
| An interactive feature does not work offline. | It may depend on JavaScript or another resource that SingleFile blocks or cannot preserve for offline use. | Review blocked-resources settings and the FAQ; then check whether retaining the relevant resource restores the behavior you need. |
| SingleFile cannot access or alter the page. | Browser security restrictions protect some pages from extension access. | Check whether the page is a protected browser page or restricted domain; the ordinary extension workflow may not be available there. |
Performance, reliability, and cost
For one page, manual annotation avoids the work of finding and maintaining selectors. For repeated saves, selectors are quicker once configured, but they need review when a site changes. Saving a complete page with its resources can create a larger HTML file than saving only selected content; choose the content and resource settings that fit your archive needs.
SingleFile is a browser extension that saves locally, so this workflow does not require a screenshot API plan. The key reliability checks are whether the browser can access the page, whether the target selector still matches, and whether the resulting file preserves the content and behavior you need. SingleFile’s documentation does not provide a universal selector catalog for ads and cookie banners.
FAQ
Can I remove several elements in one rule?
Yes. The specific-element option accepts CSS selectors separated by commas. Test the combined list to ensure each selector matches only the intended elements.
Will the saved file remember my consent choice?
The documented removal controls remove elements from the captured page. They do not establish a universal way to persist consent preferences across sites; check the actual saved page for the result you need.
Does SingleFile automatically recognize every ad or banner?
The documented workflow is manual annotation or selector-based removal. The documentation does not promise automatic recognition of every site’s ads or consent interface.
Can I save a page that the browser protects from extensions?
Some protected pages restrict extension access, so the normal SingleFile capture workflow may not work on them.


