Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AnkiWeb] apps.ankiweb does not detect Android, redirects to Linux instead #3636

Open
dae opened this issue Dec 14, 2024 · 0 comments
Open

Comments

@dae
Copy link
Member

dae commented Dec 14, 2024

Steps to replicate

Open https://apps.ankiweb.net/ on Android (any browser)
Scroll down to Download Anki
Should appear as iOS/Android, Redirects to Linux instead

Tested with Brave, Samsung, Chrome browsers
Current Script
var os = navigator.platform;
var ua = navigator.userAgent;
if (os == "Win32") {
$("a[href=#windows]").tab("show");
} else if (os == "MacIntel") {
$("a[href=#mac]").tab("show");
} else if (!!os.match(/Linux/i)) {
$("a[href=#linux]").tab("show");
} else {
if (!!(ua.match(/(iPad|iPhone|iPod)/i) || !!ua.match(/Android/i))) {
$("a[href=#ios]").tab("show");
} else {
$("#unknown").show();
}
}

Ideas
(!!os.match(/Linux/i)) could be automatically assigning every Android device as Linux before !!ua.match(/Android/i)))

Five Methods to Detect Mobile Browsers in JavaScript
if (/Mobi|Android|iPhone/i.test(navigator.userAgent)) {
// Current device is a mobile device
}

// Alternate approach
if (
navigator.userAgent.match(/Mobi/i) ||
navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/iPhone/i)
) {
// Current device is a mobile device
}

https://dev.to/timhuang/a-simple-way-to-detect-if-browser-is-on-a-mobile-device-with-javascript-44j3
const isMobile = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);

Links

Navigator: userAgent property - Web APIs | MDN
Browser detection using the user agent - HTTP | MDN
Detecting Mobile vs. Desktop Browsers in JavaScript | by Stephanie Zhan | Geek Culture | Medium
Detecting Mobile Browser - SoByte
Check mobile device using JavaScript | PixelsTech

Originally reported on https://forums.ankiweb.net/t/ankiweb-apps-ankiweb-does-not-detect-android-redirects-to-linux-instead/53110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant