prepare Backend for browser_action

This commit is contained in:
siikamiika 2020-03-02 23:26:55 +02:00
parent a05a05c4f4
commit e6347a94e7
2 changed files with 8 additions and 1 deletions

View File

@ -278,6 +278,11 @@ class Backend {
// Message handlers
async _onApiYomichanCoreReady(_params, sender) {
// tab ID isn't set in background (e.g. browser_action)
if (typeof sender.tab === 'undefined') {
return chrome.runtime.sendMessage({action: 'backendPrepared'});
}
const tabId = sender.tab.id;
return new Promise((resolve) => {
chrome.tabs.sendMessage(tabId, {action: 'backendPrepared'}, resolve);

View File

@ -48,7 +48,9 @@ function setupButtonEvents(selector, command, url) {
}
}
window.addEventListener('DOMContentLoaded', () => {
window.addEventListener('DOMContentLoaded', async () => {
await yomichan.prepare();
showExtensionInfo();
apiGetEnvironmentInfo().then(({browser}) => {