1(function() { 2 const adContainerId = 'adContainerDisplay'; 3 const APPS_URL = 'https://apps.adsgravity.io/v1/request/base'; 4 const WKEY = 'vuS2vO7P5U'; 5 const MAX_MOB_WIDTH = 1280; 6 7 // Only for A-Ads sizes 8 const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); 9 10 function uuid() { 11 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 12 var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 3 | 8); 13 return v.toString(16); 14 }); 15 } 16 17 function getDevice() { 18 return { 19 width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, 20 height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight, 21 user_agent: navigator && navigator.userAgent ? navigator.userAgent : '', 22 dnt: navigator && navigator.doNotTrack === '1' || false, 23 language: navigator && navigator.language ? (navigator.language.indexOf('-') !== -1 ? navigator.language.split('-')[0] : navigator.language) : '' 24 }; 25 } 26 27 function detectDevice(maxWidth) { 28 var touchLike; 29 if ('maxTouchPoints' in navigator) { 30 touchLike = navigator.maxTouchPoints > 0; 31 } else if (window.matchMedia && window.matchMedia('(pointer:coarse)').media === '(pointer:coarse)') { 32 touchLike = !!window.matchMedia('(pointer:coarse)').matches; 33 } else if ('orientation' in window) { 34 touchLike = true; 35 } else { 36 touchLike = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(navigator.userAgent) || 37 /\b(Android|Windows Phone|iPad|iPod)\b/i.test(navigator.userAgent); 38 } 39 var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 40 return touchLike && w < maxWidth ? 'MOBILE' : 'DESKTOP'; 41 } 42 43 const mainAd = isMobile 44 ? { code: '2247868', width: 320, height: 100 } 45 : { code: '2247890', width: 728, height: 90 }; 46 const fallbackAd = isMobile 47 ? { code: '2391765', width: 320, height: 100 } 48 : { code: '2391764', width: 728, height: 90 }; 49 50 // 1. Try to load main A-Ads banner via fetch 51 async function tryAAds(ad, onFail) { 52 const adUrl = `https://dynamic.a-ads.com/${ad.code}?size=${ad.width}x${ad.height}`; 53 console.log(`[A-ADS] Fetching: ${adUrl}`); 54 try { 55 const resp = await fetch(adUrl); 56 const html = await resp.text(); 57 if (!html.trim()) throw new Error('A-Ads: empty response'); 58 insertIframe(ad, html); 59 console.log('[A-ADS] Banner successfully loaded and inserted'); 60 } catch (e) { 61 console.warn('[A-ADS] Banner not loaded:', e.message); 62 if (onFail) onFail(); 63 } 64 } 65 66 // 2. Cointraffic â check if ad available via POST, then insert slots or fallback 67 function tryCointraffic(onFail) { 68 var container = document.getElementById(adContainerId); 69 if (!container) { 70 if (onFail) onFail(); 71 return; 72 } 73 var device = detectDevice(MAX_MOB_WIDTH); 74 var placementId = device === 'MOBILE' ? 'c7mfizl2JLe' : 'cgNBlxhmvCO'; 75 var body = { 76 website_key: WKEY, 77 device: getDevice(), 78 seats: [{ requestId: uuid(), placement_id: placementId, max_width: 0, max_height: 0 }] 79 }; 80 fetch(APPS_URL, { 81 method: 'POST', 82 credentials: 'include', 83 headers: { 'Content-Type': 'application/json' }, 84 body: JSON.stringify(body) 85 }) 86 .then(function(res) { return res.ok ? res.json() : null; }) 87 .then(function(data) { 88 if (data && data.seats && data.seats.length > 0) { 89 container.innerHTML = ''; 90 var span1 = document.createElement('span'); 91 span1.id = 'ct_c7mfizl2JLe'; 92 var span2 = document.createElement('span'); 93 span2.id = 'ct_cgNBlxhmvCO'; 94 container.appendChild(span1); 95 container.appendChild(span2); 96 } else { 97 if (onFail) onFail(); 98 } 99 }) 100 .catch(function() { 101 if (onFail) onFail(); 102 }); 103 } 104 105 // Insert iframe with srcdoc (A-Ads) 106 function insertIframe(ad, html) { 107 const container = document.getElementById(adContainerId); 108 if (!container) return; 109 container.innerHTML = ''; 110 const iframe = document.createElement('iframe'); 111 iframe.setAttribute('data-aa', ad.code); 112 iframe.setAttribute('style', `width:${ad.width}px; height:${ad.height}px; border:0px; padding:0; overflow:hidden; background-color: transparent;`); 113 iframe.setAttribute('scrolling', 'no'); 114 iframe.setAttribute('allowtransparency', 'true'); 115 iframe.setAttribute('frameborder', '0'); 116 iframe.srcdoc = html; 117 container.appendChild(iframe); 118 } 119 120 // Start chain: A-Ads main -> Cointraffic -> A-Ads fallback 121 tryAAds(mainAd, function() { 122 tryCointraffic(function() { 123 tryAAds(fallbackAd); 124 }); 125 }); 126})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.