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
Creating an Iframe with Given HTML Dynamically
How to Wait for a JavaScript Promise to Resolve Before Resuming Function
How to Run Function in Angularjs Controller on Document Ready
How to Display Pie Chart Data Values of Each Slice in Chart.Js
Resize a Div on Border Drag and Drop Without Adding Extra Markup
How to Convert HTML Table to Excel with Multiple Sheet
Updating Source Url on HTML5 Video with React
JavaScript Regex Returning True.. Then False.. Then True.. etc
Class Methods as Event Handlers in JavaScript
Failed to Load C++ Bson Extension
How to Concatenate Properties from Multiple JavaScript Objects
How to Prevent Default Event Handling in an Onclick Method
What Is the Most Efficient Way to Concatenate N Arrays
How to Return a View from an Ajax Call in Laravel 5
Remove Leading Zeros from a Number in JavaScript