1

trying to make a chrome extension that scrapes a website but it always scapes it before the content is fully loaded (tried after document read thing in manifest.json)

everytime that is getting called I am getting:

await is only valid in async functions and the top level bodies of modules
const sleepz = (ms = 0) => {
    return new Promise(r => setTimeout(r, ms));
};

const finsh_minting_shit = async(profile,user_id_now) => {
  console.log("das huhn hat ein ei gelegt");
  await sleepz(4000);
  console.log("RuehrEi")
});

window.onload = function() {
  finsh_minting_shit(profile,user_id_now);
}

also tried:

await finsh_minting_shit(profile,user_id_now);
2
  • 3
    And what would be the question?
    – Parzh
    Commented Nov 16, 2021 at 13:55
  • It sounds like the web site you are scraping is injecting content dynamically using JavaScript that doesn't settle out until well after DOMContentLoaded is fired. You need to put your delay prior to calling finish_minting_shit() - (great function name BTW :-0 ) Commented Nov 16, 2021 at 13:58

1 Answer 1

0
const sleepz = (ms = 0) => {
    return new Promise(r => setTimeout(r, ms));
};

const finsh_minting_shit = async(profile,user_id_now) => {
  console.log("das huhn hat ein ei gelegt");
  console.log("RuehrEi")
});

window.onload = function() {
  await sleepz(4000);
  finsh_minting_shit(profile,user_id_now);
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.