import browser from './browser'
/*
* Using feature detectino techniques described here:
* https://stackoverflow.com/questions/2860879/detecting-if-a-browser-is-using-private-browsing-mode
*/
export default function(cb){
    let ua = navigator.userAgent.toLowerCase();
    let name = browser();
    if(name === "firefox"){
        var db = indexedDB.open("test");
        db.onerror = function(){ 
            cb(true) 
        };
        db.onsuccess =function(){ 
            cb(false) 
        };
    } else if(name === "safari"){
        var storage = window.sessionStorage;
        try {
            storage.setItem("someKeyHere", "test");
            storage.removeItem("someKeyHere");
            cb(false);
        } catch (e) {
            if (e.code === DOMException.QUOTA_EXCEEDED_ERR && storage.length === 0) {
                //Private here
                cb(true);
            } else {
                cb(false);
            }
        }
    } else if(name === "chrome" || name === "opera"){
        var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
        if (!fs) {
            cb(false);
            return;
        }

        fs(window.TEMPORARY, 100, function (err) {
            //Incognito mode
            cb(true);
        }, function (fs) {
            cb(false);
        });
    } else if(name === "ie"){
        if(!window.indexedDB && (window.PointerEvent || window.MSPointerEvent)){
            //Privacy Mode
            cb(true);
        } else {
            cb(false);
        }
    }
}

@@ -380,33 +380,32 @@
 or = function()%7B
- 
 %0A            cb(
@@ -409,17 +409,17 @@
 cb(true)
- 
+;
 %0A       
@@ -455,17 +455,16 @@
 ction()%7B
- 
 %0A       
@@ -477,17 +477,17 @@
 b(false)
- 
+;
 %0A       
@@ -1190,19 +1190,18 @@
 nction (
-err
+fs
 ) %7B%0A    
@@ -1210,17 +1210,22 @@
       //
-I
+ Not i
 ncognito
@@ -1237,35 +1237,36 @@
 %0A            cb(
-tru
+fals
 e);%0A        %7D, f
@@ -1266,34 +1266,35 @@
    %7D, function (
-fs
+err
 ) %7B%0A            
@@ -1285,39 +1285,68 @@
 ) %7B%0A            
-cb(fals
+// Incognito mode%0A            cb(tru
 e);%0A        %7D);%0A

Fix chrome incognito detection