Skip to content

Commit ac40b83

Browse files
author
hoang.tran12
committed
fix wait for tab to load
1 parent d3c5ff6 commit ac40b83

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/helpers/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ const { version } = chrome.runtime?.getManifest() || {};
44

55
export function waitForTabToLoad(tabId) {
66
return new Promise((resolve) => {
7+
// check if tab already loaded
8+
if (chrome.tabs.get(tabId)?.status === "complete") {
9+
resolve();
10+
return;
11+
}
12+
13+
// listen for tab load
714
chrome.tabs.onUpdated.addListener(function listener(_tabId, info) {
815
if (tabId === _tabId && info.status === "complete") {
916
chrome.tabs.onUpdated.removeListener(listener);

0 commit comments

Comments
 (0)