(function () {

  console.log("✅ Content Script Loaded");

  let alreadyShown = false;

  function checkBooking() {

    if (alreadyShown) return;

    // IRCTC booking confirm page PNR selector
    let pnrElement = document.querySelector("span.train-heading");

    if (pnrElement && pnrElement.innerText.includes("PNR")) {

      let pnrText = pnrElement.innerText;

      console.log("🎯 Booking Confirmed:", pnrText);

      alert("✅ Booking Confirmed!\n" + pnrText);

      alreadyShown = true;

    } else {
      setTimeout(checkBooking, 1000);
    }
  }

  // Start checking
  setTimeout(checkBooking, 2000);

})();