Can You Determine If Chrome Is in Incognito Mode via a Script

Can you determine if Chrome is in incognito mode via a script?

The functionality of this answer is Chrome version dependant. The most recent comment was this works in v90

Yes. The FileSystem API is disabled in incognito mode. Check out https://jsfiddle.net/w49x9f1a/ when you are and aren't in incognito mode.

Sample code:

    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"));
}

Is it possible to determine if Chrome is in incognito mode via a user-script?

If you are developing an Extension then you can use the tabs API to determine if a window/tab incognito.

More information can be found on code.google.com.

If you are just working with a webpage or a userscript, it is not easy, and it is designed to be that way. However, I have noticed that all attempts to open a database (window.database) fail when in incongnito, this is because when in incognito no trace of data is allowed to be left on the users machine.

I haven't tested it but I suspect all calls to localStorage fail too.

Can you determine if Chrome is in incognito mode via a script?

The functionality of this answer is Chrome version dependant. The most recent comment was this works in v90

Yes. The FileSystem API is disabled in incognito mode. Check out https://jsfiddle.net/w49x9f1a/ when you are and aren't in incognito mode.

Sample code:

    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"));
}

Can you detect if a user is in Chrome's Guest mode?

Guest mode and Incognito Mode are different things (see more here, thanks @Quethzel Díaz). You can detect Incognito Mode using some hackish methods (see this article from late 2019, thanks to @p.s.w.g!). However, those methods are not officially supported by Google and might break in the next patch (for obvious reasons).

To answer your question: It is not possible to detect Guest Mode currently as it is simply another user in Chrome and appears the same as an unauthenticated user.



Related Topics



Leave a reply



Submit