MorrisonWill / Auto Open Puzzle Storm Fails

// ==UserScript==
// @name     Auto Open Puzzle Storm Fails
// @version  1.0.0
// @grant    none
// @match https://lichess.org/storm
// @description Automatically opens all failed puzzles after a Lichess puzzle storm run.
// @author MorrisonWill
// @license MIT
// ==/UserScript==

const targetNode = document.getElementById("main-wrap");

const config = {
  attributes: false,
  childList: true,
  subtree: true
};

const callback = (mutationList, observer) => {
  for (const mutation of mutationList) {
    if (mutation.type === 'childList') {
      if (mutation.target.nodeName === "A") {
        console.log(mutation.target);
        if (mutation.target.nextSibling.firstChild.innerHTML.includes("bad")) {
          window.open(mutation.target.href);
        }
      }
    }
  }
};

const observer = new MutationObserver(callback);

observer.observe(targetNode, config);