diff --git a/Safari Shared/Resources/background.js b/Safari Shared/Resources/background.js index 9e421bc9..2c61bb97 100644 --- a/Safari Shared/Resources/background.js +++ b/Safari Shared/Resources/background.js @@ -108,13 +108,22 @@ function storeConfigurationIfNeeded(host, response) { } } +function justShowApp() { + const id = genId(); + const showAppMessage = {name: "justShowApp", id: id, provider: "unknown", body: {}, host: ""}; + browser.runtime.sendNativeMessage("mac.tokenary.io", showAppMessage); +} + browser.browserAction.onClicked.addListener(function(tab) { const message = {didTapExtensionButton: true}; - browser.tabs.sendMessage(tab.id, message); + browser.tabs.sendMessage(tab.id, message, function(pong) { + if (pong != true) { + justShowApp(); + } + }); + if (tab.url == "" && tab.pendingUrl == "") { - const id = genId(); - const showAppMessage = {name: "justShowApp", id: id, provider: "unknown", body: {}, host: ""}; - browser.runtime.sendNativeMessage("mac.tokenary.io", showAppMessage); + justShowApp(); } }); diff --git a/Safari Shared/Resources/content.js b/Safari Shared/Resources/content.js index 191f7b4b..3d50127a 100644 --- a/Safari Shared/Resources/content.js +++ b/Safari Shared/Resources/content.js @@ -119,6 +119,7 @@ function didTapExtensionButton() { // Receive from background browser.runtime.onMessage.addListener((request, sender, sendResponse) => { if ("didTapExtensionButton" in request) { + sendResponse(true); didTapExtensionButton(); } });