main
ts 16 lines 421 Bytes
Raw
1 export type Platform = 'chrome' | 'firefox' | 'unknown'
2
3 export function getPlatform (): Platform {
4 const userAgent = navigator.userAgent
5
6 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
7 if (userAgent.includes('Firefox/')) {
8 return 'firefox'
9 }
10
11 if (userAgent.includes('Chrome/') || userAgent.includes('Chromium/')) {
12 return 'chrome'
13 }
14
15 return 'unknown'
16 }