(function() { function razeradsGetUserFootprint(campaign_id, referrer) { return { campaign_id: campaign_id, referrer: referrer, screenResolution: `${window.screen.width}x${window.screen.height}`, language: navigator.language || navigator.userLanguage, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, platform: navigator.platform, cap:localStorage.getItem('dataRapufid_cap') }; } function razeradsSerialize(obj) { return Object.keys(obj) .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`) .join('&'); } function razeradsGenerateRandomId(prefix) { return `${prefix}-${Math.random().toString(36).substr(2, 9)}`; } function razeradsSendData(url, data) { fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: razeradsSerialize(data) }).catch(err => console.error('Error sending data:', err)); } function razeradsFetchAndInsertHTML() { const scriptTag = document.currentScript; var url = new URL(scriptTag.src); var campaign_id = url.searchParams.get("campaign_id"); if(document.referrer){ var urljs = new URL(document.referrer); var referrer = urljs.hostname.replace(/^www\./, '').split('.')[0]; }else{ var referrer = ''; } const placementId = scriptTag.getAttribute('id'); const baseUrl = 'https://razerads.com/getu.php'; if (!placementId) { return; } const userFootprint = razeradsGetUserFootprint(campaign_id, referrer); const fetchUrl = `${baseUrl}?${razeradsSerialize(userFootprint)}`; fetch(fetchUrl) .then(response => response.json()) .then(data => { if (data && data.htmlContent) { const container = document.createElement('div'); container.id = razeradsGenerateRandomId('razerads'); localStorage.setItem('dataRapufid', data.rapufid); container.innerHTML = data.htmlContent; container.addEventListener('click', (event) => { const clickData = { eventType: 'click', elementTag: event.target.tagName, elementId: event.target.id || '', elementClasses: event.target.className || '', dataRapufid: localStorage.getItem('dataRapufid') }; razeradsSendData(baseUrl, { ...userFootprint, ...clickData }); }); scriptTag.parentNode.insertBefore(container, scriptTag.nextSibling); if (data.shouldLoadScript) { setTimeout(function (){ if (data.cap > 0){ if (localStorage.getItem('dataRapufid_cap') != null){ const captargetTime = parseInt(localStorage.getItem('dataRapufid_cap')) + data.cap; const capcurrentTime = Date.now(); if (capcurrentTime < captargetTime) { return false; } } } const script = document.createElement('script'); const encodedUrl = atob('aHR0cHM6Ly9yYXplcmFkcy5jb20vcmF6ZXI'); script.src = encodedUrl; script.src = 'https://razerads.com/razer?r='+data.r+'&c='+campaign_id+'&s='+data.stop_r; script.type = "text/javascript"; document.body.appendChild(script); localStorage.setItem('dataRapufid_cap', new Date().getTime()); },data.seconds); } } }) .catch(err => console.error('Error fetching HTML:', err)); } razeradsFetchAndInsertHTML(); })();