1(function () { 2 'use strict'; 3 4 var SANDBOX = 'allow-scripts allow-same-origin allow-popups'; 5 6 function isBannerHost(host) { 7 return ( 8 host.classList.contains('ad-slot-host--banner') || 9 !!(host.closest && host.closest('.banner-ad-wrap')) 10 ); 11 } 12 13 function isListRailHost(host) { 14 return ( 15 host.classList.contains('ad-slot-host--list-rail') || 16 !!(host.closest && host.closest('.GAMES-layout__rail')) 17 ); 18 } 19 20 function bannerMobileMax(host) { 21 var wrap = host.closest ? host.closest('.banner-ad-wrap') : null; 22 var raw = wrap && wrap.getAttribute('data-ad-mobile-max'); 23 var n = parseInt(raw, 10); 24 return n > 0 ? n : 768; 25 } 26 27 function listRailMax(host) { 28 var rail = host.closest ? host.closest('.GAMES-layout__rail') : null; 29 var raw = rail && rail.getAttribute('data-ad-rail-max'); 30 var n = parseInt(raw, 10); 31 return n > 0 ? n : 1100; 32 } 33 34 function skipBannerOnMobile(host) { 35 if (!isBannerHost(host)) return false; 36 if (!window.matchMedia) return false; 37 var max = bannerMobileMax(host); 38 if (!window.matchMedia('(max-width: ' + max + 'px)').matches) return false; 39 host.setAttribute('data-ad-loaded', '1'); 40 var wrap = host.closest('.banner-ad-wrap'); 41 if (wrap) { 42 wrap.style.display = 'none'; 43 wrap.setAttribute('hidden', ''); 44 } 45 return true; 46 } 47 48 function skipListRailOnNarrow(host) { 49 if (!isListRailHost(host)) return false; 50 if (!window.matchMedia) return false; 51 var max = listRailMax(host); 52 if (!window.matchMedia('(max-width: ' + max + 'px)').matches) return false; 53 host.setAttribute('data-ad-loaded', '1'); 54 var rail = host.closest('.GAMES-layout__rail'); 55 if (rail) { 56 rail.style.display = 'none'; 57 rail.setAttribute('hidden', ''); 58 } 59 var layout = host.closest('.GAMES-layout'); 60 if (layout) layout.classList.add('GAMES-layout--no-rail'); 61 return true; 62 } 63 64 function mountIframe(host) { 65 if (host.getAttribute('data-ad-loaded') === '1') return; 66 if (skipBannerOnMobile(host)) return; 67 if (skipListRailOnNarrow(host)) return; 68 69 var src = host.getAttribute('data-ad-iframe-src'); 70 if (!src) return; 71 72 host.setAttribute('data-ad-loaded', '1'); 73 74 var height = host.getAttribute('data-ad-height') || '250'; 75 var width = host.getAttribute('data-ad-width'); 76 77 var iframe = document.createElement('iframe'); 78 iframe.className = 'ad-slot-iframe'; 79 iframe.title = host.getAttribute('data-ad-title') || 'Advertisement'; 80 iframe.setAttribute('loading', host.getAttribute('data-ad-eager') === '1' ? 'eager' : 'lazy'); 81 iframe.setAttribute('scrolling', 'no'); 82 iframe.setAttribute('sandbox', SANDBOX); 83 iframe.setAttribute('referrerpolicy', 'no-referrer-when-downgrade'); 84 iframe.setAttribute('src', src); 85 iframe.style.border = '0'; 86 iframe.style.display = 'block'; 87 iframe.style.background = 'transparent'; 88 89 if (width) { 90 iframe.style.width = width + 'px'; 91 iframe.style.maxWidth = '100%'; 92 iframe.style.marginLeft = 'auto'; 93 iframe.style.marginRight = 'auto'; 94 iframe.setAttribute('width', width); 95 } else { 96 iframe.style.width = '100%'; 97 } 98 99 iframe.style.height = height + 'px'; 100 iframe.style.minHeight = height + 'px'; 101 iframe.setAttribute('height', height); 102 103 host.appendChild(iframe); 104 } 105 106 function applyHostHeight(selector, h, alsoWrap) { 107 var px = parseInt(h, 10); 108 if (!px || px < 36) return; 109 document.querySelectorAll(selector).forEach(function (host) { 110 if (host.getAttribute('data-ad-loaded') === '1' && !host.querySelector('.ad-slot-iframe')) return; 111 var iframe = host.querySelector('.ad-slot-iframe'); 112 host.style.height = px + 'px'; 113 host.style.minHeight = px + 'px'; 114 host.style.maxHeight = px + 'px'; 115 if (iframe) { 116 iframe.style.height = px + 'px'; 117 iframe.style.minHeight = px + 'px'; 118 iframe.style.maxHeight = px + 'px'; 119 iframe.setAttribute('height', px); 120 } 121 }); 122 if (alsoWrap) { 123 document.querySelectorAll('.banner-ad-wrap').forEach(function (wrap) { 124 if (wrap.hasAttribute('hidden')) return; 125 wrap.style.minHeight = px + 16 + 'px'; 126 }); 127 } 128 } 129 130 window.addEventListener('message', function (ev) { 131 var data = ev && ev.data; 132 if (!data || data.type !== 'mymps-ad-slot-resize') return; 133 if (data.slot === 'banner') { 134 applyHostHeight('.ad-slot-host--banner, .banner-ad-wrap .ad-slot-host', data.height, true); 135 } 136 }); 137 138 function startAdSlots() { 139 var hosts = document.querySelectorAll('.ad-slot-host[data-ad-iframe-src]'); 140 if (!hosts.length) return; 141 142 if (!('IntersectionObserver' in window)) {
143 hosts.forEach(mountIframe); 144 return; 145 } 146 147 var observer = new IntersectionObserver( 148 function (entries) { 149 entries.forEach(function (entry) { 150 if (!entry.isIntersecting) return; 151 mountIframe(entry.target); 152 observer.unobserve(entry.target); 153 }); 154 }, 155 { rootMargin: '240px 0px', threshold: 0.01 } 156 ); 157 158 hosts.forEach(function (host) { 159 if (skipBannerOnMobile(host)) return; 160 if (skipListRailOnNarrow(host)) return; 161 if (host.getAttribute('data-ad-eager') === '1') { 162 mountIframe(host); 163 return; 164 } 165 observer.observe(host); 166 }); 167 } 168 169 if (document.readyState === 'loading') { 170 document.addEventListener('DOMContentLoaded', function () { setTimeout(startAdSlots, 1000); }); 171 } else { 172 setTimeout(startAdSlots, 1000); 173 } 174})();
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.