Skip to content

Commit

Permalink
fix(extension): re-run script when execution context is empty (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored Oct 9, 2024
1 parent 8b15bde commit 00aad0f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/chrome-extension/src/devtools-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,20 @@ function injectScript(scriptName: string, cb: () => void) {
script.parentNode.removeChild(script);
})()
`
chrome.devtools.inspectedWindow.eval(src, (res, err) => {
if (err)
console.error(err)
let timeoutId: number = null!
function execute() {
clearTimeout(timeoutId)
chrome.devtools.inspectedWindow.eval(src, (res, err) => {
if (err) {
// @ts-expect-error skip type check
timeoutId = setTimeout(() => {
execute()
}, 100)
return
}

cb()
})
cb()
})
}
execute()
}

0 comments on commit 00aad0f

Please sign in to comment.