For a Chrome Desktop Extension home page, I'm trying to detect whether a user is using Chrome for Desktop or Chrome for Mobile on Android. Currently the script below identifies Android Chrome the same as Desktop chrome. On desktop Chrome it should show "chrome" link; however, if someone is on Chrome for Android, it should show the "mobile-other" link.
Script:
<script>$(document).ready(function(){
var ua = navigator.userAgent;
if (/Chrome/i.test(ua))
$('a.chrome').show();
else if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(ua))
$('a.mobile-other').show();
else
$('a.desktop-other').show();
});</script>
Chrome Android User Agent:
Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>
else if (/Android|...
to just anif (/Android|...
? – Jotunif
and theelse if
logic. – Jotun