Fix connection error when opening popup

This commit is contained in:
sienori 2019-08-22 15:09:29 +09:00
parent 66647f69f6
commit 1700ebb114

View file

@ -18,11 +18,13 @@ const getTabInfo = async () => {
const tabUrl = browser.tabs.sendMessage(tab.id, { message: "getTabUrl" }); const tabUrl = browser.tabs.sendMessage(tab.id, { message: "getTabUrl" });
const selectedText = browser.tabs.sendMessage(tab.id, { message: "getSelectedText" }); const selectedText = browser.tabs.sendMessage(tab.id, { message: "getSelectedText" });
const isEnabledOnPage = browser.tabs.sendMessage(tab.id, { message: "getEnabled" }); const isEnabledOnPage = browser.tabs.sendMessage(tab.id, { message: "getEnabled" });
const tabInfo = await Promise.all([tabUrl, selectedText, isEnabledOnPage]);
return { return {
isConnected: true, isConnected: true,
url: await tabUrl, url: tabInfo[0],
selectedText: await selectedText, selectedText: tabInfo[1],
isEnabledOnPage: await isEnabledOnPage isEnabledOnPage: tabInfo[2]
}; };
} catch (e) { } catch (e) {
return { isConnected: false, url: "", selectedText: "", isEnabledOnPage: false }; return { isConnected: false, url: "", selectedText: "", isEnabledOnPage: false };