I am building a Chrome extension and want to inject DOM elements or modify some.
For that, I try with my content.js
to wait for the DOM to load elements and then use it. However, the DOM element I'm targetting seems to be build after an Async/Await call.
How to access DOM element once Async/Await calls are finished ?
From my content.js :
window.document.onreadystatechange = function () {
console.log(window.document.readyState); /* "complete" */
if (window.document.readyState === "complete") {
console.log(window.document.getElementById('chips')); /* null */
}
}
The URL I'm targetting is a YouTube live : https://www.youtube.com/watch?v=gxG3pdKvlIs&ab_channel=FRANCE24 (for instance). Running in the DevConsole : window.document.getElementById('chips')
correctly log the element.