add browser typing to global def

This commit is contained in:
Kyle Spearrin 2018-08-14 21:29:32 -04:00
parent 2d6107fae1
commit 418951021f
2 changed files with 5 additions and 4 deletions

View File

@ -3,8 +3,8 @@ export class BrowserApi {
static isSafariApi: boolean = (typeof safari !== 'undefined') &&
navigator.userAgent.indexOf(' Safari/') !== -1 && navigator.userAgent.indexOf('Chrome') === -1;
static isChromeApi: boolean = !BrowserApi.isSafariApi && (typeof chrome !== 'undefined');
static isFirefoxOnAndroid: boolean =
navigator.userAgent.indexOf('Firefox/') !== -1 && navigator.userAgent.indexOf('Android') !== -1;
static isFirefoxOnAndroid: boolean = navigator.userAgent.indexOf('Firefox/') !== -1 &&
navigator.userAgent.indexOf('Android') !== -1;
static async getTabFromCurrentWindowId(): Promise<any> {
if (BrowserApi.isChromeApi) {
@ -210,8 +210,8 @@ export class BrowserApi {
// COMPAT: Reactivating the active tab dismisses the popout-tab. The promise final
// condition is only called if the popout wasn't already dismissed (future proofing).
// BUGZILLA: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
browser.tabs.update({active: true}).finally(win.close);
} else if (browserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
browser.tabs.update({ active: true }).finally(win.close);
}  else if (browserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
win.close();
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
safari.extension.popovers[0].hide();

1
src/globals.d.ts vendored
View File

@ -2,4 +2,5 @@ declare function escape(s: string): string;
declare function unescape(s: string): string;
declare var opr: any;
declare var chrome: any;
declare var browser: any;
declare var safari: any;