Html not loaded even after window.addEventListener(‘load’, do_something) is invoked

I’m working on a browser extension that scrapes data from a webpage. I’ve added a method to scrape data, which is invoked via a load listener:
window.addEventListener('load', scrapeSomething)
However, when I refresh the page and put a breakpoint in the Chrome Developer Tools, I notice that the HTML is still not fully loaded when the method is invoked. For instance, the HTML content at the time of invocation is just:
<div id="hiddenFrame"></div>

To mitigate this issue temporarily, the previous code had a 5-second delay before running the scraping logic:

let callDebouncer = () => {
setTimeout(() => {
//scraping part
},5000);  };
window.addEventListener('load', callDebouncer);

I want to avoid using a fixed delay and instead rely on a listener to ensure the page is fully loaded before scraping. Is there an alternative way to achieve this?