MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / waitForTabToLoad

Function waitForTabToLoad

scripts/helpers/utils.js:90–106  ·  view source on GitHub ↗
(tabId)

Source from the content-addressed store, hash-verified

88}
89
90export function waitForTabToLoad(tabId) {
91 return new Promise((resolve) => {
92 // check if tab already loaded
93 if (chrome.tabs.get(tabId)?.status === "complete") {
94 resolve();
95 return;
96 }
97
98 // listen for tab load
99 chrome.tabs.onUpdated.addListener(function listener(_tabId, info) {
100 if (tabId === _tabId && info.status === "complete") {
101 chrome.tabs.onUpdated.removeListener(listener);
102 resolve();
103 }
104 });
105 });
106}
107
108export function runFunc(fnPath = "", params = [], global = {}) {
109 return new Promise((resolve) => {

Callers 1

openWebAndRunScriptFunction · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected