I tried below code to check the incognito mode using javascript. it's not working in chrome Version 76.0.3809.100.
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;if (!fs) {console.log("check failed?");} else {fs(window.TEMPORARY,100,console.log.bind(console, "not in incognito mode"),console.log.bind(console, "incognito mode"));}
I tried below one also but this one is using temporary memory and finding out so we cant say that this is stable.
async function start() {if ('storage' in navigator && 'estimate' in navigator.storage) {const {usage, quota} = await navigator.storage.estimate();console.log(`Using ${usage} out of ${quota} bytes.`);if(quota < 120000000){console.log('Incognito')} else {
console.log('Not Incognito') } } else {console.log('Can not detect')}}start();