Created
January 26, 2023 00:53
-
-
Save yashshah1/39a96f8939790b73d4c2005f125fe6fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // from: https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browsers | |
| const useBrowserType = () => { | |
| if (!window) { | |
| return {}; | |
| } | |
| const isIE = false || !!document.documentMode; | |
| const isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); | |
| return { | |
| isOpera: | |
| (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0, | |
| isFirefox: typeof InstallTrigger !== 'undefined', | |
| isSafari: | |
| /constructor/i.test(window.HTMLElement) || | |
| (function (p) { | |
| return p.toString() === '[object SafariRemoteNotification]'; | |
| })(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification)), | |
| isIE, | |
| isChrome, | |
| isEdge: !isIE && !!window.StyleMedia, | |
| isEdgeChromium: isChrome && navigator.userAgent.indexOf('Edg') != -1, | |
| }; | |
| }; | |
| export default useBrowser; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment