| OLD | NEW |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | 4 |
| 5 require.scopes.info = { | 5 (function() { |
| 6 addonName: {{metadata.get('general', 'basename')|json}}, | 6 var platformVersion = null; |
| 7 addonVersion: {{version|json}}, | 7 var application = null; |
| 8 var applicationVersion; |
| 8 | 9 |
| 9 application: {{type|json}}, | 10 var regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g; |
| 10 get applicationVersion() | 11 var match; |
| 12 |
| 13 while (match = regexp.exec(navigator.userAgent)) |
| 11 { | 14 { |
| 12 {%- if type == 'opera' %} | 15 var app = match[1]; |
| 13 var match = /\bOPR\/(\S+)/.exec(navigator.userAgent); | 16 var ver = match[2]; |
| 14 return (match ? match[1] : "0"); | |
| 15 {%- else %} | |
| 16 return this.platformVersion; | |
| 17 {%- endif %} | |
| 18 }, | |
| 19 | 17 |
| 20 platform: "chromium", | 18 if (app == "Chrome") |
| 21 get platformVersion() | 19 { |
| 20 platformVersion = ver; |
| 21 } |
| 22 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari") |
| 23 { |
| 24 // For compatibility with legacy websites, Chrome's UA |
| 25 // also includes a Mozilla, AppleWebKit and Safari token. |
| 26 // Any further name/version pair indicates a fork. |
| 27 application = app == "OPR" ? "opera" : app.toLowerCase(); |
| 28 applicationVersion = ver; |
| 29 } |
| 30 } |
| 31 |
| 32 // not a Chromium-based UA, probably modifed by the user |
| 33 if (!platformVersion) |
| 22 { | 34 { |
| 23 var match = /\bChrome\/(\S+)/.exec(navigator.userAgent); | 35 application = "unknown"; |
| 24 return (match ? match[1] : "0"); | 36 applicationVersion = platformVersion = "0"; |
| 25 } | 37 } |
| 26 }; | 38 |
| 39 // no additional name/version, so this is upstream Chrome |
| 40 if (!application) |
| 41 { |
| 42 application = "chrome"; |
| 43 applicationVersion = platformVersion; |
| 44 } |
| 45 |
| 46 require.scopes.info = { |
| 47 addonName: {{ metadata.get('general', 'basename')|json }}, |
| 48 addonVersion: {{ version|json }}, |
| 49 |
| 50 application: application, |
| 51 applicationVersion: applicationVersion, |
| 52 |
| 53 platform: "chromium", |
| 54 platformVersion: platformVersion |
| 55 }; |
| 56 })(); |
| OLD | NEW |