Detect Incognito Mode

This is a rarely needed situation, which we refer to as a Dark Site, in reference to the Dark Web- sites that "hide" from the traditional mechanics of discovery, history, tracking, and so on.

Here we're focused on detecting Incognito Mode.

Goals

  • Detect Incognito mode

    • Various browsers

  • Warn user if not in incognito mode

    • Give proceed ( that's fine ) option

    • Give exit option

      • Instructions on how to invoke incognito mode on that browser

      • Clipboard copy URL

      • Purge / replace browser history

        • Chain purge

        • Cookies

        • webStorage

Use Cases

The primary general use case here is to minimize the risk of unwanted browser-history tracking on a site.

There are of course many illicit use cases here, but the scenario we're interested in supporting is domestic abuse hotlines, where someone may seek help and information but needs to be able to do so safely with minimal risk of someone else discovering their investigations.

Implementation Notes

Drawing

Detecting Incognito Mode

Detecting if a browser is in incognito mode is not straightforward, as browsers are designed to prevent detection of incognito mode to protect user privacy. However, there are some heuristics and methods you can use to make an educated guess. Below is an example of how to detect incognito mode in various browsers and how to prevent the user from proceeding if they are not in incognito mode.

Chrome and Edge

You can use the FileSystem API to detect incognito mode. In incognito mode, the FileSystem API is disabled, and trying to use it will result in an error.

Firefox

Firefox does not disable the FileSystem API, so the above method won't work. Instead, you can check the storage quota, as incognito mode typically has a much smaller quota.

Safari

Safari has different limitations in private browsing mode, such as no local storage access. You can test for these limitations.

Preventing User from Proceeding

If the user is not in incognito mode, you can redirect them to a different page or display a message preventing further interaction.

Combining the detection methods for Chrome, Edge, Firefox, and Safari:

History Purge

Reverse Proxy

Last updated

Was this helpful?