add browser typing to global def
This commit is contained in:
parent
2d6107fae1
commit
418951021f
|
@ -3,8 +3,8 @@ export class BrowserApi {
|
||||||
static isSafariApi: boolean = (typeof safari !== 'undefined') &&
|
static isSafariApi: boolean = (typeof safari !== 'undefined') &&
|
||||||
navigator.userAgent.indexOf(' Safari/') !== -1 && navigator.userAgent.indexOf('Chrome') === -1;
|
navigator.userAgent.indexOf(' Safari/') !== -1 && navigator.userAgent.indexOf('Chrome') === -1;
|
||||||
static isChromeApi: boolean = !BrowserApi.isSafariApi && (typeof chrome !== 'undefined');
|
static isChromeApi: boolean = !BrowserApi.isSafariApi && (typeof chrome !== 'undefined');
|
||||||
static isFirefoxOnAndroid: boolean =
|
static isFirefoxOnAndroid: boolean = navigator.userAgent.indexOf('Firefox/') !== -1 &&
|
||||||
navigator.userAgent.indexOf('Firefox/') !== -1 && navigator.userAgent.indexOf('Android') !== -1;
|
navigator.userAgent.indexOf('Android') !== -1;
|
||||||
|
|
||||||
static async getTabFromCurrentWindowId(): Promise<any> {
|
static async getTabFromCurrentWindowId(): Promise<any> {
|
||||||
if (BrowserApi.isChromeApi) {
|
if (BrowserApi.isChromeApi) {
|
||||||
|
@ -210,8 +210,8 @@ export class BrowserApi {
|
||||||
// COMPAT: Reactivating the active tab dismisses the popout-tab. The promise final
|
// 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).
|
// condition is only called if the popout wasn't already dismissed (future proofing).
|
||||||
// BUGZILLA: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
|
// BUGZILLA: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
|
||||||
browser.tabs.update({active: true}).finally(win.close);
|
browser.tabs.update({ active: true }).finally(win.close);
|
||||||
} else if (browserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
} else if (browserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
||||||
win.close();
|
win.close();
|
||||||
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
|
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
|
||||||
safari.extension.popovers[0].hide();
|
safari.extension.popovers[0].hide();
|
||||||
|
|
|
@ -2,4 +2,5 @@ declare function escape(s: string): string;
|
||||||
declare function unescape(s: string): string;
|
declare function unescape(s: string): string;
|
||||||
declare var opr: any;
|
declare var opr: any;
|
||||||
declare var chrome: any;
|
declare var chrome: any;
|
||||||
|
declare var browser: any;
|
||||||
declare var safari: any;
|
declare var safari: any;
|
||||||
|
|
Loading…
Reference in New Issue