Oh, okay. Interesting implementation with window.orientation. Firefox has support for window.screen.orientation which is on a standards track [1] – but this also works on desktop so it’s not useful here.
What about using the following code?
if(window.orientation || navigator.userAgent.match(/android/i)) {
console.log('mobile!');
}
[1] https://www.w3.org/TR/screen-orientation/