Advertisement
rogerin

Untitled

Dec 14th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. new Promise(function (resolve) {
  2.     var db,
  3.     on = function(){ resolve(true) },
  4.     off = function(){ resolve(false) },
  5.     tryls = function tryls() {
  6.         try {
  7.             localStorage.length ? off() : (localStorage.x = 1, localStorage.removeItem("x"), off());
  8.         } catch (e) {
  9.             // Safari only enables cookie in private mode
  10.             // if cookie is disabled then all client side storage is disabled
  11.             // if all client side storage is disabled, then there is no point
  12.             // in using private mode
  13.             navigator.cookieEnabled ? on() : off();
  14.         }
  15.     }
  16.  
  17.     // Blink (chrome & opera)
  18.     window.webkitRequestFileSystem ? webkitRequestFileSystem(0, 0, off, on)
  19.     // FF
  20.     : "MozAppearance" in document.documentElement.style ? (db = indexedDB.open("test"), db.onerror = on, db.onsuccess = off)
  21.     // Safari
  22.     : /constructor/i.test(window.HTMLElement) ? tryls()
  23.     // IE10+ & edge
  24.     : !window.indexedDB && (window.PointerEvent || window.MSPointerEvent) ? on()
  25.     // Rest
  26.     : off();
  27. }).then(function (isPrivateMode) {
  28.     console.log('is private mode: ' + isPrivateMode)
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement