ScreenshotNeo

BlogHow-to

How to Keep SingleFileZ from Saving Cookie Banners and Pop-Ups in an Archive

Remove visible cookie banners and pop-ups from SingleFile archives with site-specific CSS selectors, one-off editor cleanup, or a pre-capture script.

By the ScreenshotNeo team4 October 20269 min read

To keep a visible cookie banner or pop-up out of a saved archive, use SingleFile’s “remove specific elements” option and enter CSS selectors for the unwanted containers. For a one-off page, use the editor’s selection and removal controls instead. Then open the saved file and confirm the unwanted overlay is gone while the page content you need remains.

SingleFileZ is no longer the project’s current name or documentation path: its official repository says it “has been completely merged into SingleFile.” The repository points users to SingleFile’s options page to choose a self-extracting file format. Existing SingleFileZ installations and add-on listings may still be around, but the current instructions below use SingleFile’s documentation. SingleFileZ repository

1. Remove a banner with a CSS selector

  1. Open the SingleFile options from your browser’s extension menu.
  2. Find HTML content > remove specific elements.
  3. Add the selector for the banner or pop-up container. Separate multiple selectors with commas.
  4. Save the options, return to the target page, and save it with SingleFile.
  5. Open the resulting archive and check the page’s main content, layout, images, and any interactive parts you need.

SingleFile’s help describes this option as removing elements specified by a list of CSS selectors. The selector is specific to the site’s markup; the official documentation does not provide a universal selector that works across sites. SingleFile help

Find the right selector

Inspect the target page in your browser’s developer tools. Use the element picker to select the visible banner, then move upward through its ancestors until you find the smallest container that includes the whole overlay and excludes page content you want to keep. Look for a stable ID or class on that container. A selector that targets only a button may remove the close or accept button but leave the banner; a selector that targets a broad page wrapper may remove far too much.

Test the candidate selector on the actual site. In the developer tools console, document.querySelectorAll('YOUR_SELECTOR').length shows how many elements match. Replace YOUR_SELECTOR with the candidate selector, including quotes as needed. Inspect the matches before committing the selector to extension options. A selector that matches zero elements may be mistyped, may run into a page structure such as a shadow root, or may not match until the banner has appeared.

Example shape only: if inspection shows a site-specific container with a stable class, enter that site’s actual class selector. Do not assume a generic name such as .cookie-banner exists or is safe on every site.

Use multiple selectors carefully

Separate selectors with commas to remove different containers, such as a consent panel and a separate newsletter modal. Keep the list narrow. Before saving, check each selector individually and confirm it does not also match article sections, navigation, or unrelated dialogs. If a site redesign changes its markup, revisit and retest the selectors.

2. Use the editor for a one-off cleanup

If you only need to clean one archive, manual selection avoids maintaining a persistent site-specific rule:

  1. Open the page and invoke SingleFile’s selection workflow without first selecting page text or an element.
  2. Hover over the unwanted banner or pop-up and select the element or enclosing container to remove.
  3. Use the selection controls to expand or narrow the selection until it covers the overlay and not the page beneath it.
  4. Save the page, then inspect the archive.

The help documents keyboard controls for selection and removal, including Tab to expand the selection, Shift-Tab to reduce it, Space to remove the selected element, Ctrl-Z to undo, and Escape to reset the selection. The exact controls can vary by version and platform, so consult the help shown by your installed version. Selection and removal controls

3. Choose a method that fits how often you save the site

Method Repeatability Precision depends on Maintenance
Remove specific elements option Repeatable for pages matching the saved selector Choosing the correct site-specific container Retest if the site changes its markup
Editor selection Manual for each archive Selecting the right element on that page No selector list to maintain
Pre-capture user script Repeatable when the script matches the page JavaScript selector and capture timing Requires script setup and ongoing maintenance

For a single page, the editor is usually the simplest path. For recurring captures from a site, a tested selector is easier to repeat. A pre-capture script is an advanced option when you need custom logic and are comfortable maintaining it.

4. Advanced option: remove elements before capture with a user script

SingleFile documents a user-script event that runs before a page is saved. The example below removes elements matching a site-specific selector just before capture. Replace the example selector with one you verified on the target site.

// ==UserScript==
// @name         Remove selected overlays before SingleFile capture
// @namespace    https://github.com/gildas-lormeau/SingleFile
// @version      1.0
// @description  Remove a site-specific banner before SingleFile saves the page
// @match        https://www.example.com/*
// @grant        none
// ==/UserScript==

(() => {
  const selector = "REPLACE_WITH_A_SITE_SPECIFIC_SELECTOR";

  dispatchEvent(new CustomEvent("single-file-user-script-init"));

  addEventListener("single-file-on-before-capture-request", () => {
    document.querySelectorAll(selector).forEach(element => element.remove());
  });
})();

This sample intentionally does not use a made-up universal selector. Set @match to the site you intend to clean and replace the placeholder with a verified selector. If you want to remove more than one container, use a comma-separated selector list. Confirm that the result retains the content you need.

For the extension, SingleFile’s wiki says user scripts require enabling the hidden userScriptEnabled option by exporting settings, changing the value, and importing the settings again, as well as using an extension to store and run user scripts. The wiki also documents the event mechanism and a CLI option for scripts. Follow the current instructions there; do not assume an older SingleFileZ build has the same controls. SingleFile user-script instructions

Removing an element before capture changes the DOM that SingleFile processes. If the page inserts the overlay late, or uses a shadow root or embedded frame, a simple document-level selector may not reach it. In those cases, use the editor, inspect the page structure, or adapt the script to the actual page. Keep the script limited to the target site to avoid removing similarly named elements elsewhere.

5. Do not confuse hidden-element cleanup with banner removal

The “remove hidden elements” option concerns hidden elements. It is not documented as an automatic detector for visible cookie banners. For a visible consent panel, use an explicit selector or remove it in the editor, then inspect the saved page. The SingleFile FAQ describes hidden-element cleanup separately from other page-saving controls. SingleFile FAQ

6. Verify the saved archive

  • The cookie banner or pop-up is absent from the archived page.
  • The main article or page content remains intact.
  • Images and embedded content you need are present.
  • Removing the overlay did not also remove its parent page container.
  • The archive opens in the format you selected and works for your intended offline use.
  • For repeated captures, the selector still matches the intended container on a fresh page load.

7. Troubleshooting

Symptom Likely cause Fix
The banner still appears in the archive The selector does not match the overlay’s container, or the element appears after the cleanup point. Inspect the live DOM, test the selector against the actual container, and confirm the option was saved. For late-created content, try the editor or a user script suited to the page’s timing.
The banner’s text disappears but its background remains The selector matched an inner child rather than the outer overlay container. Inspect parent elements and select the smallest ancestor that contains the complete overlay without containing the page content.
Important content disappears too The selector is too broad or matches a shared wrapper. Undo or remove the selector, narrow it to the overlay container, and test the match before saving again.
A selector works on one page but not another The site uses different markup, or the overlay is conditionally rendered. Inspect each page type and add only the necessary specific selectors. Recheck after site changes.
The selector matches zero elements Typo, changed class, delayed overlay, or encapsulated DOM such as a shadow root. Check the selector in developer tools after the overlay appears. Inspect the DOM boundary and use manual removal if the selector cannot reach it.
“Remove hidden elements” leaves the visible banner That setting is for hidden elements, not a guaranteed visible-overlay blocker. Use “remove specific elements” with a tested selector or remove the element in the editor.
The user script does not run User scripts may not be enabled or installed as required, or the event setup differs in the installed version. Follow the current SingleFile wiki setup, verify the script’s site match, and inspect the browser’s script extension and console for errors.
The archive is missing scripts or interactive behavior SingleFile’s default behavior may remove scripts because they can alter rendering and may not work offline. Review the relevant SingleFile FAQ options for preserving scripts and raw page content. Preserving scripts can affect reliability and should be tested for the page you need.

8. Performance, reliability, and storage notes

Selector removal is a small, targeted cleanup step; the practical reliability issue is selector quality and whether the site’s markup remains stable. A stored selector saves repeated manual work, but a site redesign can make it stop matching or cause it to match something else. Review saved pages when the target site changes.

SingleFile’s FAQ notes that some cleanup options, including removing hidden elements and unused styles, can slow the save process and lists options that can be disabled to save time and CPU. Those choices can affect what is retained, so weigh capture speed against archive completeness. SingleFile performance notes

SingleFile performs its work in the browser, according to its FAQ. There is no per-shot service charge for using the extension described here. Archive size and the resources retained depend on the page and capture settings; inspect the saved file before relying on it as a complete offline record.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. A GET request returns a PNG, JPEG, WebP, or PDF. Use it when a rendered screenshot is enough and you do not need a self-contained SingleFile HTML archive. Cookie banners, pop-ups, and chat widgets are removed before the shot; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. An MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Read the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Create a free ScreenshotNeo account for 1,000 screenshots a month with no card.

FAQ

Does SingleFileZ still work?

The SingleFileZ repository says the project was merged into SingleFile. Existing installations may remain usable, but current instructions and options should be checked against SingleFile.

Can I remove a banner from an archive I already saved?

The documented workflows remove elements while preparing a page for saving. To clean an existing archive, edit its HTML with a suitable editor or recapture the source page using a selector or the removal editor.

Will the same selector work on every site?

No universal selector is established in the official documentation. Inspect and test the actual target site.

The described archive cleanup removes page elements from the saved result. It is not a substitute for choosing consent preferences on the live site.