Index: templates/geckoInfo.js.tmpl |
=================================================================== |
--- a/templates/geckoInfo.js.tmpl |
+++ b/templates/geckoInfo.js.tmpl |
@@ -8,17 +8,29 @@ |
exports.addonVersion = {{ version|json }}; |
exports.application = "unknown"; |
exports.applicationVersion = "0"; |
exports.platform = "gecko"; |
exports.platformVersion = "0"; |
-let match = /\brv:(\d+(?:\.\d+)?)\b/.exec(navigator.userAgent); |
+exports.deviceForm = "unknown"; |
+ |
+// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox |
+let match = /\(((?:[^;]+; )+)rv:(\d+(?:\.\d+)?)\)/.exec(navigator.userAgent); |
if (match) |
- exports.platformVersion = match[1]; |
+{ |
+ exports.platformVersion = match[2]; |
+ |
+ let platformTokens = match[1].split("; "); |
+ |
+ if (platformTokens.includes("Mobile")) |
+ exports.deviceForm = "phone"; |
+ else if (platformTokens.includes("Tablet")) |
+ exports.deviceForm = "tablet"; |
+} |
browser.runtime.getBrowserInfo().then(browserInfo => |
{ |
exports.application = browserInfo.name.toLowerCase(); |
exports.applicationVersion = browserInfo.version; |
}); |