Last active
July 8, 2022 07:24
-
-
Save AvocadoVenom/f0c89425e2c8f5928bb3405301343e15 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
| const userAgent: string = navigator.userAgent || navigator.vendor || window.opera | |
| const isMobileDevice = (): boolean => { | |
| const regexs = [/(Android)(.+)(Mobile)/i, /BlackBerry/i, /iPhone|iPod/i, /Opera Mini/i, /IEMobile/i] | |
| return regexs.some((b) => userAgent.match(b)) | |
| } | |
| const isTabletDevice = (): boolean => { | |
| const regex = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/ | |
| return regex.test(userAgent.toLowerCase()) | |
| } | |
| const isDesktopDevice = (): boolean => !isMobileDevice() && !isTabletDevice() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment