mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 14:52:13 +00:00
Use Bowser to Detect Mobile
This commit is contained in:
parent
242a277484
commit
c9347885e0
1 changed files with 4 additions and 17 deletions
|
|
@ -1,24 +1,11 @@
|
|||
// Copyright (C) 2017-2022 Smart code 203358507
|
||||
|
||||
function iOS() {
|
||||
return [
|
||||
'iPad Simulator',
|
||||
'iPhone Simulator',
|
||||
'iPod Simulator',
|
||||
'iPad',
|
||||
'iPhone',
|
||||
'iPod'
|
||||
].includes(navigator.platform)
|
||||
|| (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
|
||||
}
|
||||
const Bowser = require('bowser');
|
||||
|
||||
function android() {
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
return ua.indexOf('android') > -1;
|
||||
}
|
||||
const browser = Bowser.parse(window.navigator?.userAgent || '');
|
||||
|
||||
module.exports = () => {
|
||||
if (iOS()) return 'ios';
|
||||
if (android()) return 'android';
|
||||
if (browser?.os?.name === 'iOS') return 'ios';
|
||||
if (browser?.os?.name === 'Android') return 'android';
|
||||
return false;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue