Skip to content

Instantly share code, notes, and snippets.

@Julien-laville
Last active March 26, 2019 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Julien-laville/6dde02f8c125e3de377e7709799b7c73 to your computer and use it in GitHub Desktop.
Save Julien-laville/6dde02f8c125e3de377e7709799b7c73 to your computer and use it in GitHub Desktop.
function waitForSelector(selector,cb, limit = 30) {
if(limit === 0) return
if(document.querySelector(selector)) {
cb()
} else {
setTimeout(() => {waitForSelector(selector,cb, limit --)},300)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment