/* ---- ad network staggered multi-pop (the money engine) ---- */
window.__adNetworks = ["hilltopads"];
window.__maxPops = 1;
window.__staggerMs = 400;
/* Fire staggered pops when the user interacts (clicks play, etc.).
* Called from app.js on video play click. Each network's script auto-fires
* on click, but we also manually trigger any that support a JS API. */
window.fireStaggeredPops = function () {
var nets = window.__adNetworks || [];
var max = window.__maxPops || nets.length;
var delay = window.__staggerMs || 400;
var fired = 0;
for (var i = 0; i < Math.min(max, nets.length); i++) {
(function (netName, idx) {
setTimeout(function () {
try {
// Most popunder networks fire automatically on click. For networks
// with a JS API, we trigger it here. The script tags handle the
// auto-fire; this is a fallback for manual triggering.
if (netName === 'hilltopads' && window.hilltopadsPop) {
window.hilltopadsPop();
} else if (netName === 'mondiad' && window.mondiadPop) {
window.mondiadPop();
} else if (netName === 'popcash' && window._pop) {
// PopCash uses _pop as the trigger function
window._pop = window._pop || [];
window._pop.push({ e: 'click' });
}
fired++;
} catch (e) {
// Network script not loaded or API changed — skip silently
}
}, idx * delay);
})(nets[i], i);
}
return fired;
};
/* Auto-fire on first user interaction (click anywhere on the page).
* This is the "smart trick" — the user clicks play (or anywhere), and we
* trigger multiple ad networks in sequence. The networks' own scripts also
* auto-fire on click, so this is a supplementary trigger. */
(function () {
var fired = false;
function onFirstInteraction() {
if (fired) return;
fired = true;
// Small delay to let the page settle, then fire
setTimeout(function () {
if (window.fireStaggeredPops) window.fireStaggeredPops();
}, 200);
document.removeEventListener('click', onFirstInteraction);
document.removeEventListener('keydown', onFirstInteraction);
}
document.addEventListener('click', onFirstInteraction);
document.addEventListener('keydown', onFirstInteraction);
})();