I have been coding this Chrome Extension for the past few weeks, and when I was almost done and everything was working, Bybit decided to change their HTML code and consequently my code stopped working. Now, what I want to do is that I need to observe a <div> element that contains 21 <div> elements. in those 21 elements, there are 3 or 4 spans and I need to access the second span. Below is my JS code:
function obser1() {
const trades = document.querySelector("#root > main > div.main-left > div.react-grid-layout > div:nth-child(3) > div > div.by-card__body > div > div");
tradescards.push(trades.childNodes);
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.addedNodes.length) {
console.log(trades);
console.log(mutation.addedNodes);
});
observer.observe(trades, {
childList: true,
subtree: true,
attributes: true,
characterData: true
})
}
Please keep in mind trades returns the parent div of the 21 divs.