Skip to content

Instantly share code, notes, and snippets.

@overdodactyl
Last active November 24, 2018 06:34
Show Gist options
  • Save overdodactyl/934ab50cad62166e3a108210e141bcc8 to your computer and use it in GitHub Desktop.
Save overdodactyl/934ab50cad62166e3a108210e141bcc8 to your computer and use it in GitHub Desktop.
A simple test, based on access to IndexedDB, to determine if Firefox is in private browsing mode.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PB Test</title>
<meta name="author" content="overdodactyl">
</head>
<body>
<h1>Private Browsing Test</h1>
<p>This is a simple test, based on access to IndexedDB, to determine if Firefox is in private browsing mode.</p>
<p id="test">Testing...</p>
<script>
var db = indexedDB.open("test");
var result = document.getElementById("test");
db.onerror = function(){
result.innerHTML = "Private Browsing detected!";
result.style.color = 'red';
};
db.onsuccess =function(){
result.innerHTML = "Private Browsing not detected!";
result.style.color = 'green';
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment