Just show app when content script is not there

This commit is contained in:
Ivan Grachev 2022-08-18 18:06:30 +03:00
parent 102d6959fd
commit dbe7512750
2 changed files with 14 additions and 4 deletions

View File

@ -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();
}
});

View File

@ -119,6 +119,7 @@ function didTapExtensionButton() {
// Receive from background
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
if ("didTapExtensionButton" in request) {
sendResponse(true);
didTapExtensionButton();
}
});