Skip to content

Instantly share code, notes, and snippets.

@hogashi
Created January 3, 2019 17:23
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 hogashi/fc0db47a579f65583148ffb161fd17a6 to your computer and use it in GitHub Desktop.
Save hogashi/fc0db47a579f65583148ffb161fd17a6 to your computer and use it in GitHub Desktop.
欲しいタグが出てくるまで待つ (拡張機能で DOMContentLoaded が発火しないときとか)
new Promise(resolve => {
const timer = setInterval(() => {
if (document.querySelector('body')) {
clearInterval(timer);
resolve();
}
console.log('no body-tag yet');
}, 100);
})
.then(() => {
// safe
const body = document.querySelector('body');
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment