Przeglądaj źródła

check chrome.runtime.lastError when retrieving tab info

Gildas 7 lat temu
rodzic
commit
4851c586cb
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      extension/core/scripts/bg/bg.js

+ 5 - 1
extension/core/scripts/bg/bg.js

@@ -24,7 +24,11 @@
 
 	const CHROME_STORE_URL = "https://chrome.google.com";
 
-	chrome.tabs.onActivated.addListener(activeInfo => chrome.tabs.get(activeInfo.tabId, tab => singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url))));
+	chrome.tabs.onActivated.addListener(activeInfo => chrome.tabs.get(activeInfo.tabId, tab => {
+		if (!chrome.runtime.lastError) {
+			singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url));
+		}
+	}));
 	chrome.tabs.onCreated.addListener(tab => singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url)));
 	chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url)));
 	chrome.tabs.onRemoved.addListener(tabId => singlefile.ui.notifyTabRemoved(tabId));