Fix screenshot page
When a OS wasn't correctly detected, the page showed an error message.
This is now fixed, and the page now also detects the Android OS.
Fixed: misc:60, misc:45
Change-Id: I9ed86787064466069c29e1cc022b821007586ee3
diff --git a/overrides/assets/javascripts/ua_utils.js b/overrides/assets/javascripts/ua_utils.js
index fdfc383..a07ba70 100644
--- a/overrides/assets/javascripts/ua_utils.js
+++ b/overrides/assets/javascripts/ua_utils.js
@@ -1,7 +1,7 @@
// @Author: avm99963 (https://www.avm99963.com)
/* @License: The MIT License (MIT)
-Copyright (c) 2021 Adrià Vilanova Martínez
+Copyright (c) 2022 Adrià Vilanova Martínez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -23,6 +23,7 @@
// Detect the current OS
function detectOS() {
+ var androidRegex = /Android/i;
var linuxRegex = /Linux/i;
var winRegex = /Win/i;
var winNT7 = /NT 7/i;
@@ -44,6 +45,9 @@
}
return uaPromise.then(ua => {
+ // The order in which OSs are checked is important! (e.g. Android contains
+ // the substring "Linux" in its user agent)
+ if (androidRegex.test(ua)) return 'android';
if (linuxRegex.test(ua)) return 'linux';
if (winRegex.test(ua)) {
if (winNT7.test(ua) || winNT6.test(ua)) return 'win_7_or_less';