I\'m making a small chrome extension and for it I need to grab a div
from the DOM to manipulate. I get the DOM but I\'m having trouble grabbing the required d
Probably you're trying to get the Element before it's even loaded on the page.
If so, you can wrap your code into the DOMContentLoaded
event:
document.addEventListener('DOMContentLoaded', function() {
console.log(document.getElementById(':ik').textContent);
});
But if you really want to get the element by its aria
label, you can do that:
document.querySelector('div[aria-label="Message Body"]');
But this way is much less performatic, and you'll need to do exactly what I've mentioned above too.