var scarcityTimerConfig = {"_id":"T5Bn3vA9z4QYW8o6Q","name":"24 bis abgelaufen für Sofort Cash Formel Salespage","style":{},"startNumber":24,"stopSeconds":1800,"createdAt":"2021-03-23T15:24:10.318Z","userId":"ZcvkGraKrMwGuAz8o","stopNumber":0};function randomIntFromInterval(e,t){return Math.floor(Math.random()*(t-e+1)+e)}if(scarcityTimerConfig){var counterElementBefore,counterElementWrap=document.createElement("div");scarcityTimerConfig.textBefore&&((counterElementBefore=document.createElement("span")).innerText=scarcityTimerConfig.textBefore+" ",counterElementWrap.appendChild(counterElementBefore));var counterElementAfter,counterElement=document.createElement("span");counterElementWrap.appendChild(counterElement),scarcityTimerConfig.textAfter&&((counterElementAfter=document.createElement("span")).innerText=" "+scarcityTimerConfig.textAfter,counterElementWrap.appendChild(counterElementAfter)),document.currentScript.parentNode.insertBefore(counterElementWrap,document.currentScript);var start=parseInt(scarcityTimerConfig.startNumber,10),storageKey="scarcity-timer-start-"+scarcityTimerConfig._id;localStorage.getItem(storageKey)&&!isNaN(parseInt(localStorage.getItem(storageKey),10))&&(start=parseInt(localStorage.getItem(storageKey),10));var stopNumber=parseInt(scarcityTimerConfig.stopNumber,10)||1;if(!isNaN(start)&&0<start){var counterIteration=0,decreaseCount=function(e,t,n,r,o){counterIteration++,localStorage.setItem(o,t),t--,n<(counterElement.innerText=t)&&e(t,n,r,o)},stopSeconds=isNaN(scarcityTimerConfig.stopSeconds)?1e3*(start-stopNumber):1e3*parseInt(scarcityTimerConfig.stopSeconds,10);if(stopSeconds){var counterTimes=[0],currentMs=0,totalMs=stopSeconds;console.log(totalMs);for(var iterations=start-stopNumber,timeChunkSize=Math.round(stopSeconds/iterations),counterIteration=start;stopNumber<=counterIteration;counterIteration--){var ms=randomIntFromInterval(timeChunkSize-.5*timeChunkSize,timeChunkSize+.5*timeChunkSize);console.log(ms);var remeaningSecs=totalMs-(currentMs+=ms);if(console.log(remeaningSecs),remeaningSecs<0||.8*totalMs<=currentMs){var lastChunksCount=Math.ceil(timeChunkSize/remeaningSecs),lastChunksSize=remeaningSecs/lastChunksCount;console.log(lastChunksCount,lastChunksSize);for(var lastChunkIteration=0;lastChunkIteration<lastChunksCount;lastChunkIteration++)currentMs+=lastChunksSize,counterTimes.push(lastChunksSize);break}counterTimes.push(ms)}console.log(timeChunkSize,counterTimes);var counterTimeIteration=0,next=function(e,t,n,r){setTimeout(function(){decreaseCount(function(e,t,n,r){counterTimeIteration<counterTimes.length&&(counterTimeIteration++,next(e,t,n,r))},e,t,n,r)},counterTimes[counterTimeIteration])};next(start,stopNumber,0,storageKey)}else decreaseCount(function(){var o=function(e,t,n,r){setTimeout(function(){decreaseCount(o,e,t,n,r)},randomIntFromInterval(1e3,1e4))};o(start,stopNumber,0,storageKey)},start,stopNumber,0,storageKey)}}