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 selectedText = browser.tabs.sendMessage(tab.id, { message: "getSelectedText" });
const isEnabledOnPage = browser.tabs.sendMessage(tab.id, { message: "getEnabled" });
const tabInfo = await Promise.all([tabUrl, selectedText, isEnabledOnPage]);
return {
isConnected: true,
url: await tabUrl,
selectedText: await selectedText,
isEnabledOnPage: await isEnabledOnPage
url: tabInfo[0],
selectedText: tabInfo[1],
isEnabledOnPage: tabInfo[2]
};
} catch (e) {
return { isConnected: false, url: "", selectedText: "", isEnabledOnPage: false };