1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
var detectIncognito=function(e){var o="Unknown";function n(n){e({isPrivate:n,browserName:o})}function t(e){return e===eval.toString().length}function i(){var e,t,i=window;if(void 0!==navigator.maxTouchPoints)if(void 0!==i.safari&&void 0===i.DeviceMotionEvent)o="Safari for macOS",function(){try{window.safari.pushNotification.requestPermission("https://example.com","private",{},(function(){}))}catch(e){return n(!new RegExp("gesture").test(e))}n(!1)}();else{if(void 0===i.DeviceMotionEvent)throw new Error("detectIncognito Could not identify this version of Safari");o="Safari for iOS",e=!1,(t=document.createElement("iframe")).style.display="none",document.body.appendChild(t),t.contentWindow.applicationCache.addEventListener("error",(function(){return e=!0,n(!0)})),setTimeout((function(){e||n(!1)}),100)}else!function(){var e=window.openDatabase,o=window.localStorage;try{e(null,null,null,null)}catch(e){return n(!0)}try{o.setItem("test","1"),o.removeItem("test")}catch(e){return n(!0)}n(!1)}()}function r(){navigator.webkitTemporaryStorage.queryUsageAndQuota((function(e,o){var t;n(o<(void 0!==(t=window).performance&&void 0!==t.performance.memory&&void 0!==t.performance.memory.jsHeapSizeLimit?performance.memory.jsHeapSizeLimit:1073741824))}),(function(e){throw new Error("detectIncognito somehow failed to query storage quota: "+e.message)}))}function a(){void 0!==Promise&&void 0!==Promise.allSettled?r():(0,window.webkitRequestFileSystem)(0,1,(function(){n(!1)}),(function(){n(!0)}))}!function(){if(void 0!==(r=navigator.vendor)&&0===r.indexOf("Apple")&&t(37))i();else if(function(){var e=navigator.vendor;return void 0!==e&&0===e.indexOf("Google")&&t(33)}())e=navigator.userAgent,o=e.match(/Chrome/)?e.match(/Edg/)?"Edge":void 0!==navigator.brave?"Brave":void 0!==navigator.opr?"Opera":"Chrome":"Chromium",a();else if(void 0!==document.documentElement&&void 0!==document.documentElement.style.MozAppearance&&t(37))o="Firefox",n(void 0===navigator.serviceWorker);else{if(void 0===navigator.msSaveBlob||!t(39))throw new Error("detectIncognito cannot determine the browser");o="Internet Explorer",n(void 0===window.indexedDB)}var e,r}()}; |