summaryrefslogtreecommitdiff
path: root/ext/bg/js/api.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 17:20:55 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 17:20:55 -0400
commitcb236a743081e8ea4809a8a559abf9f0f22e771c (patch)
tree581b4ccc531d2191a2855aefd1bfe556ac228443 /ext/bg/js/api.js
parentc92fc11fcdad294059931a0927ec7f7701eb5be5 (diff)
Add apiGetEnvironmentInfo function
Diffstat (limited to 'ext/bg/js/api.js')
-rw-r--r--ext/bg/js/api.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 9fefadca..da5ae4fe 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -270,3 +270,31 @@ function apiInjectStylesheet(css, sender) {
});
});
}
+
+async function apiGetEnvironmentInfo() {
+ const browser = await apiGetBrowser();
+ const platform = await new Promise((resolve) => chrome.runtime.getPlatformInfo(resolve));
+ return {
+ browser,
+ platform: {
+ os: platform.os
+ }
+ };
+}
+
+async function apiGetBrowser() {
+ if (EXTENSION_IS_BROWSER_EDGE) {
+ return 'edge';
+ }
+ if (typeof browser !== 'undefined') {
+ try {
+ const info = await browser.runtime.getBrowserInfo();
+ if (info.name === 'Fennec') {
+ return 'firefox-mobile';
+ }
+ } catch (e) { }
+ return 'firefox';
+ } else {
+ return 'chrome';
+ }
+}