2022-07-26 10:58:28 +00:00
|
|
|
// @ts-ignore
|
2020-01-29 12:30:17 +00:00
|
|
|
import Platform from '../react/Platform';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the current environment is a mobile device.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isMobileBrowser() {
|
|
|
|
return Platform.OS === 'android' || Platform.OS === 'ios';
|
|
|
|
}
|
2020-02-25 12:41:13 +00:00
|
|
|
|
2021-02-23 07:39:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the current environment is an ios mobile device.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isIosMobileBrowser() {
|
|
|
|
return Platform.OS === 'ios';
|
|
|
|
}
|
|
|
|
|
2020-02-25 12:41:13 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the chrome extensions defined in the config file are installed or not.
|
|
|
|
*
|
|
|
|
* @param {Object} config - Objects containing info about the configured extensions.
|
|
|
|
*
|
|
|
|
* @returns {Promise[]}
|
|
|
|
*/
|
2022-07-26 10:58:28 +00:00
|
|
|
export function checkChromeExtensionsInstalled(config: any = {}) {
|
|
|
|
const isExtensionInstalled = (info: any) => new Promise(resolve => {
|
2020-02-25 12:41:13 +00:00
|
|
|
const img = new Image();
|
|
|
|
|
|
|
|
img.src = `chrome-extension://${info.id}/${info.path}`;
|
2021-06-10 12:48:44 +00:00
|
|
|
img.setAttribute('aria-hidden', 'true');
|
2020-02-25 12:41:13 +00:00
|
|
|
img.onload = function() {
|
|
|
|
resolve(true);
|
|
|
|
};
|
|
|
|
img.onerror = function() {
|
|
|
|
resolve(false);
|
|
|
|
};
|
|
|
|
});
|
2022-07-26 10:58:28 +00:00
|
|
|
const extensionInstalledFunction = (info: any) => isExtensionInstalled(info);
|
2020-02-25 12:41:13 +00:00
|
|
|
|
|
|
|
return Promise.all(
|
2022-07-26 10:58:28 +00:00
|
|
|
(config.chromeExtensionsInfo || []).map((info: any) => extensionInstalledFunction(info))
|
2020-02-25 12:41:13 +00:00
|
|
|
);
|
|
|
|
}
|