/* Add custom Js code below */ //----------------------صفقة اليوم------------------ document.addEventListener("DOMContentLoaded", function() { // Get the current time var currentTime = new Date().getTime(); // Get the last time the popup was shown from localStorage var lastPopupTime = localStorage.getItem("lastPopupTime"); // Calculate the time difference in minutes var timeDiff = (currentTime - lastPopupTime) / (1000 * 60); // Check if the popup has been closed before and if 3 minutes have passed since the last time if (!lastPopupTime || timeDiff > 7) { // Create the popup element var popup = document.createElement("div"); popup.classList.add("popup-container"); popup.innerHTML = `
`; // Append the popup to the body document.body.appendChild(popup); // Function to close the popup and set the flag in localStorage function closePopup() { popup.style.display = "none"; localStorage.setItem("popupClosed", "true"); // Store the current time as the last popup time localStorage.setItem("lastPopupTime", currentTime); } // Automatically close the popup after 5 seconds setTimeout(closePopup, 6000); // Close the popup when the close button is clicked popup.querySelector(".close-btn").addEventListener("click", closePopup); // Close the popup and redirect when the offer button is clicked popup.querySelector(".offer-btn").addEventListener("click", function(e) { closePopup(); window.location.href = this.href; e.preventDefault(); // Prevent the default link action to avoid reopening the popup }); } });