mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 07:42:24 -08:00
17 lines
504 B
TypeScript
17 lines
504 B
TypeScript
import { UAParser } from 'ua-parser-js';
|
|
|
|
const result = new UAParser(window.navigator.userAgent).getResult();
|
|
|
|
const isMobileOrTablet = (() => {
|
|
const { os, device } = result;
|
|
if (device.type === 'mobile' || device.type === 'tablet') return true;
|
|
if (os.name === 'Android' || os.name === 'iOS') return true;
|
|
return false;
|
|
})();
|
|
|
|
const isMac = result.os.name === 'Mac OS';
|
|
|
|
export const ua = () => result;
|
|
export const isMacOS = () => isMac;
|
|
export const mobileOrTablet = () => isMobileOrTablet;
|