I'm creating an extension in Firefox, I'm trying to reading the content using ElementByClassName function. Like this.
console.log(document.getElementsByClassName('flip-card-back')[0].innerHTML)
this works perfectlly in my console and return the result expected. Nevertheless when I'm implementing this in my extension, this doesn't work.
This is what I tried.
console.log('test')
console.log(document.getElementsByClassName('flip-card-back')[0].innerHTML)
window.addEventListener('load', function () {
var eles = document.getElementsByClassName('flip-card-back')[0].innerHTML;
console.log(eles);
})
The first console is printed correctly, unlike the other ones.
Notice that I've used window event listener function to wait for the DOM to load. But still didn't work. I also printed the HTMLColecction itself, (without tanking the item 0) and it seems to work. What I'm doing wrong?
This is the page I'm trying to take the content from. here
Thanks!