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';
diff --git a/overrides/assets/javascripts/version_page.js b/overrides/assets/javascripts/version_page.js
index ecc57d1..977e865 100644
--- a/overrides/assets/javascripts/version_page.js
+++ b/overrides/assets/javascripts/version_page.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
@@ -40,7 +40,8 @@
}
function convert2OmahaOS(os) {
- if (os == 'linux' || os == 'mac' || os == 'cros') return os;
+ if (os == 'linux' || os == 'mac' || os == 'cros' || os == 'android')
+ return os;
if (os == 'win_7_or_less' || os == 'win_latest') return 'win64';
return undefined;
}
@@ -50,6 +51,7 @@
if (os == 'mac') return 'Mac';
if (os == 'cros') return 'Chrome OS';
if (os == 'win_7_or_less' || os == 'win_latest') return 'Windows';
+ if (os == 'android') return 'Android';
return undefined;
}
@@ -80,9 +82,12 @@
var actualChrome =
matches?.[0]?.versions?.filter?.(function(val, index, array) {
return val.channel === 'stable';
- });
+ }) ??
+ [];
actualVersion = actualChrome?.[0]?.version?.split?.('.')?.[0];
- if (majorVersion < actualVersion) {
+ if (actualVersion === undefined) {
+ document.getElementById('updated').innerHTML = '';
+ } else if (majorVersion < actualVersion) {
document.getElementById('updated').innerHTML =
'¡Oh, no! Google Chrome ' +
'<a href=\'https://support.google.com/chrome/answer/95414\'>no está actualizado</a>.';