document.addEventListener("DOMContentLoaded", function() {
// Check if the popup was already interacted with
if (localStorage.getItem("locationChosen")) {
return; // Stop the script if the user already chose a location
}
// Wait for the popup to appear in case it loads asynchronously
let checkPopup = setInterval(function() {
let popup = document.querySelector(".sqs-popup-overlay");
if (popup) {
clearInterval(checkPopup); // Stop checking once popup is found
// Add event listener to buttons inside the popup
document.querySelectorAll(".sqs-popup-overlay a, .sqs-popup-overlay button").forEach(button => {
button.addEventListener("click", function() {
// Hide the popup and prevent it from appearing again
localStorage.setItem("locationChosen", "true");
popup.style.display = "none";
});
});
}
}, 500); // Check every 500ms until the popup appears
});