1313 */
1414
1515/**
16- * Returns whether the current runtime is a mobile one (true) or not (false).
16+ * Return the browser's browser info or fallback to an empty object.
17+ *
18+ * This is a workaround for Chrome/ium browsers that do not support runtime.getBrowserInfo().
19+ * See https://github.com/TinyWebEx/AutomaticSettings/issues/18
1720 *
1821 * @private
1922 * @returns {Promise<bool> }
2023 */
21- async function isMobile ( ) {
24+ async function getBrowserInfo ( ) {
25+ if ( ! browser . runtime . getBrowserInfo ) {
26+ return { } ;
27+ }
28+
29+ return await browser . runtime . getBrowserInfo ( ) ;
30+ }
31+
32+ /**
33+ * Returns whether the current runtime is a mobile one (true) or not (false).
34+ *
35+ * @public
36+ * @returns {Promise<bool> }
37+ */
38+ export async function isMobile ( ) {
2239 const platformInfo = await browser . runtime . getPlatformInfo ( ) ;
2340
2441 return platformInfo . os === "android" ;
@@ -29,11 +46,11 @@ async function isMobile() {
2946*
3047* This includes Firefox and Thunderbird e.g.
3148*
32- * @private
49+ * @public
3350* @returns {Promise<bool> }
3451*/
35- async function isMozilla ( ) {
36- const browserInfo = await browser . runtime . getBrowserInfo ( ) ;
52+ export async function isMozilla ( ) {
53+ const browserInfo = await getBrowserInfo ( ) ;
3754
3855 // Thunderbird is explicitly checked as a workaround as Thunderbird does not return the vendor correctly
3956 // see https://bugzilla.mozilla.org/show_bug.cgi?id=1702722
@@ -46,11 +63,11 @@ async function isMozilla() {
4663*
4764* This does not include Thunderbird!
4865*
49- * @private
66+ * @public
5067* @returns {Promise<bool> }
5168*/
52- async function isFirefox ( ) {
53- const browserInfo = await browser . runtime . getBrowserInfo ( ) ;
69+ export async function isFirefox ( ) {
70+ const browserInfo = await getBrowserInfo ( ) ;
5471
5572 return browserInfo . name === "Firefox" ;
5673}
0 commit comments