55
Browser Incognito Mode. Is it possible to identify via JavaScript?
source link: https://www.tuicool.com/articles/3mieaqY
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
is-incognito-mode
:bust_in_silhouette: Function to identify whether browser is in incognito mode :eyes:
How to use
To install library:
# yarn yarn add is-incognito-mode # npm npm install is-incognito-mode --save
// ES6 modules import isIncognito from 'is-incognito-mode'; // CommonJS modules const isIncognito = require('is-incognito-mode').default; /* Function returns Promise, which could be: - resolved with true, if Incognito mode is opened - resolved with false, if regular window is opened - rejected if no possibility to identify */ isIncognito() .then(isPrivate => { if (isPrivate) { alert('There is no porn! Why are you using Incognito mode?'); } else { console.log('Incognito mode is NOT activated') } }) .catch(e => { console.log(e.message); })
Demo
Incognito Window Regular WindowAPI
isIncognito: Promise<boolean>
Result Promise
is
true false
Contributing
is-incognito-mode
is open-source library, opened for contributions
License
is-incognito-mode
is MIT licensed
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK