const univresalP = function() { const puURLstrpcht = 'https://go.mnaspm.com/smartpop/097828d6ab3996e0801beb09d3b3a110184a298a8e0fdc70828b7a417b402ed4?userId=c11b667e1e8a26cf7f31362ebc0577ab36a4ec57b491bae9f3f8939c70b4b75e'; const interval = 86400; const maxPopunders = 3; const delay = 30; // Initialize the timestamp and counter if they don't exist if (typeof localStorage.puTSstrpcht === 'undefined') { localStorage.puTSstrpcht = Math.round(+new Date() / 1000); } if (typeof localStorage.puCountstrpcht === 'undefined') { localStorage.puCountstrpcht = 0; } if (typeof localStorage.puLstrpcht === 'undefined') { localStorage.puLstrpcht = 0; } const checkInterval = function() { const currentTS = Math.round(+new Date() / 1000); if (parseInt(localStorage.puTSstrpcht) <= currentTS - interval) { localStorage.puCountstrpcht = 0; localStorage.puTSstrpcht = currentTS; } }; const handlePopunder = function(e) { if (parseInt(localStorage.puCountstrpcht) >= maxPopunders) { checkInterval(); } if (parseInt(localStorage.puLstrpcht) + delay > Math.round(+new Date() / 1000)) { return; } if (parseInt(localStorage.puCountstrpcht) < maxPopunders) { e && e.preventDefault(); window.open(puURLstrpcht, "_blank") localStorage.puTSstrpcht = Math.round(+new Date() / 1000); localStorage.puCountstrpcht = parseInt(localStorage.puCountstrpcht) + 1; localStorage.puLstrpcht = localStorage.puTSstrpcht; } }; document.addEventListener('click', function(e) { if (e.target.closest('iframe')) { return; } if (e.target.tagName != 'A') { return; } handlePopunder(e); }); const focusListener = function() { window.addEventListener('blur', function onBlur() { if (document.activeElement.tagName === 'IFRAME') { handlePopunder(); // handlePopunder({ // preventDefault: () => {} // }); } window.removeEventListener('blur', onBlur); setTimeout(() => { window.addEventListener('blur', onBlur); }, 100); }); }; focusListener(); }; univresalP();