React app (and Next.js in particular) loads page DOM after `DOMContentLoaded’ event is fired. If content script needs to interact with React app DOM, it needs to wait for them to appear. The following code triggers too early.
document.addEventListener('DOMContentLoaded', function(event) {
console.log('DOMContentLoaded before class:', document.getElementById('root').textContent);
});
So how to wait for React DOM to load?