Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new Promise(function (resolve) {
- var db,
- on = function(){ resolve(true) },
- off = function(){ resolve(false) },
- tryls = function tryls() {
- try {
- localStorage.length ? off() : (localStorage.x = 1, localStorage.removeItem("x"), off());
- } catch (e) {
- // Safari only enables cookie in private mode
- // if cookie is disabled then all client side storage is disabled
- // if all client side storage is disabled, then there is no point
- // in using private mode
- navigator.cookieEnabled ? on() : off();
- }
- }
- // Blink (chrome & opera)
- window.webkitRequestFileSystem ? webkitRequestFileSystem(0, 0, off, on)
- // FF
- : "MozAppearance" in document.documentElement.style ? (db = indexedDB.open("test"), db.onerror = on, db.onsuccess = off)
- // Safari
- : /constructor/i.test(window.HTMLElement) ? tryls()
- // IE10+ & edge
- : !window.indexedDB && (window.PointerEvent || window.MSPointerEvent) ? on()
- // Rest
- : off();
- }).then(function (isPrivateMode) {
- console.log('is private mode: ' + isPrivateMode)
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement