1(function () { 2 'use strict'; 3 4 var MOBILE_ONE_BANNER_BREAKPOINT = 767; 5 var RESIZE_DEBOUNCE_MS = 200; 6 var FALLBACK_DELAY_AFTER_LOAD_MS = 6500; 7 var IDLE_TIMEOUT_MS = 8500; 8 var resizeTimer = 0; 9 var initialized = false; 10 11 var AD_SCRIPTS = [ 12 { 13 src: 'https://stats.hprofits.com/advertisement.js', 14 defer: true 15 }, 16 { 17 id: 'hpt-rdr', 18 src: 'https://cdn.wasp-182b.com/renderer/renderer.js', 19 async: true, 20 data: { 21 'hpt-url': 'wasp-182b.com', 22 'static-path': 'https://cdn.wasp-182b.com' 23 } 24 } 25 ]; 26 27 function injectFooterBannerStyles() { 28 if (document.getElementById('cw-footer-banner-styles')) { 29 return; 30 } 31 32 var css = '' + 33 '.cw-footer-ad-wrap{' + 34 'display:block!important;' + 35 'width:100%!important;' + 36 'clear:both!important;' + 37 'margin:16px auto 18px!important;' + 38 'padding:0 10px!important;' + 39 'box-sizing:border-box!important;' + 40 'text-align:center!important;' + 41 '}' + 42 '.cw-footer-ad-wrap:empty{display:none!important;}' + 43 '.cw-footer-ad-row{' + 44 'display:grid!important;' + 45 'grid-template-columns:repeat(3,minmax(0,1fr))!important;' + 46 'gap:12px!important;' + 47 'width:100%!important;' + 48 'max-width:936px!important;' + 49 'margin:0 auto!important;' + 50 'align-items:start!important;' + 51 'justify-items:center!important;' + 52 'box-sizing:border-box!important;' + 53 '}' + 54 '.cw-footer-ad-cell{' + 55 'display:block!important;' + 56 'width:100%!important;' + 57 'max-width:300px!important;' + 58 'min-width:0!important;' + 59 'margin:0!important;' + 60 'padding:0!important;' + 61 'overflow:hidden!important;' + 62 'text-align:center!important;' + 63 'box-sizing:border-box!important;' + 64 '}' + 65 '.cw-footer-ad-inner{' + 66 'display:block!important;' + 67 'width:100%!important;' + 68 'max-width:300px!important;' + 69 'min-width:0!important;' + 70 'margin:0 auto!important;' + 71 'padding:0!important;' + 72 'overflow:hidden!important;' + 73 'text-align:center!important;' + 74 'box-sizing:border-box!important;' + 75 '}' + 76 '.cw-footer-ad-inner>*{' + 77 'max-width:100%!important;' + 78 'box-sizing:border-box!important;' + 79 '}' + 80 '.cw-footer-ad-inner a{' + 81 'display:inline-block!important;' + 82 'max-width:100%!important;' + 83 '}' + 84 '.cw-footer-ad-inner img,' + 85 '.cw-footer-ad-inner iframe,' + 86 '.cw-footer-ad-inner object,' + 87 '.cw-footer-ad-inner embed{' + 88 'max-width:100%!important;' + 89 'border:0!important;' + 90 '}' + 91 '@media(max-width:1009px) and (min-width:768px){' + 92 '.cw-footer-ad-row{' + 93 'grid-template-columns:repeat(2,minmax(0,300px))!important;' + 94 'max-width:624px!important;' + 95 '}' + 96 '}' + 97 '@media(max-width:767px){' + 98 '.cw-footer-ad-wrap{' + 99 'margin:12px auto 14px!important;' + 100 'padding:0 10px!important;' + 101 '}' + 102 '.cw-footer-ad-row{' + 103 'grid-template-columns:minmax(0,300px)!important;' + 104 'max-width:300px!important;' + 105 'gap:0!important;' + 106 '}' + 107 '.cw-footer-ad-cell,' + 108 '.cw-footer-ad-inner{' + 109 'max-width:300px!important;' + 110 '}' + 111 '.cw-footer-ad-cell:nth-child(n+2){' + 112 'display:none!important;' + 113 '}' + 114 '}'; 115 116 var style = document.createElement('style'); 117 style.id = 'cw-footer-banner-styles'; 118 style.textContent = css; 119 document.head.appendChild(style); 120 } 121 122 function appendScript(config, onload) { 123 if (!config || !config.src) { 124 if (typeof onload === 'function') { 125 onload(); 126 } 127 return; 128 } 129 130 var existing = document.querySelector('script[src="' + config.src + '"]'); 131 if (existing) { 132 if (config.id && !existing.id) { 133 existing.id = config.id; 134 } 135 if (config.data) {
136 Object.keys(config.data).forEach(function (key) { 137 if (!existing.hasAttribute('data-' + key)) { 138 existing.setAttribute('data-' + key, config.data[key]); 139 } 140 }); 141 } 142 existing.dataset.cwLoaded = '1'; 143 if (typeof onload === 'function') { 144 window.setTimeout(onload, 0); 145 } 146 return; 147 } 148 149 var script = document.createElement('script'); 150 script.type = 'text/javascript'; 151 script.src = config.src; 152 153 if (config.id) { 154 script.id = config.id; 155 } 156 if (config.async) { 157 script.async = true; 158 } else { 159 script.defer = config.defer !== false; 160 } 161 if (config.data) { 162 Object.keys(config.data).forEach(function (key) { 163 script.setAttribute('data-' + key, config.data[key]); 164 }); 165 } 166 167 script.addEventListener('load', function () { 168 script.dataset.cwLoaded = '1'; 169 if (typeof onload === 'function') { 170 onload(); 171 } 172 }, { once: true }); 173 174 script.addEventListener('error', function () { 175 if (typeof onload === 'function') { 176 onload(); 177 } 178 }, { once: true }); 179 180 document.body.appendChild(script); 181 } 182 183 function includeAdScripts(done) { 184 var index = 0; 185 186 function next() { 187 if (index >= AD_SCRIPTS.length) { 188 if (typeof done === 'function') { 189 done(); 190 } 191 return; 192 } 193 194 appendScript(AD_SCRIPTS[index], function () { 195 index += 1; 196 next(); 197 }); 198 } 199 200 next(); 201 } 202 203 function fixAdLinks(container) { 204 container.querySelectorAll('a[href]').forEach(function (link) { 205 if (!link.getAttribute('target')) { 206 link.setAttribute('target', '_blank'); 207 } 208 209 var rel = (link.getAttribute('rel') || '').toLowerCase().split(/\s+/).filter(Boolean); 210 ['nofollow', 'sponsored', 'noopener'].forEach(function (item) { 211 if (rel.indexOf(item) === -1) { 212 rel.push(item); 213 } 214 }); 215 link.setAttribute('rel', rel.join(' ')); 216 }); 217 } 218 219 function runInsertedScripts(container) { 220 container.querySelectorAll('script').forEach(function (oldScript) { 221 var newScript = document.createElement('script'); 222 223 Array.prototype.slice.call(oldScript.attributes).forEach(function (attr) { 224 newScript.setAttribute(attr.name, attr.value); 225 }); 226 227 if (oldScript.textContent) { 228 newScript.textContent = oldScript.textContent; 229 } 230 231 oldScript.parentNode.replaceChild(newScript, oldScript); 232 }); 233 } 234 235 function updateRenderer() { 236 if (window.hptRdr && typeof window.hptRdr.update === 'function') { 237 try { 238 window.hptRdr.update(); 239 } catch (e) {} 240 } 241 } 242 243 function getWantedCount() { 244 var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0; 245 return width <= MOBILE_ONE_BANNER_BREAKPOINT ? 1 : 3; 246 } 247 248 function setUrlCount(src, count) { 249 var fallback = '/partials/footer-banners.php?count=' + count; 250 try { 251 var url = new URL(src || fallback, window.location.origin); 252 url.searchParams.set('count', String(count)); 253 return url.pathname + url.search; 254 } catch (e) { 255 return fallback; 256 } 257 } 258 259 function loadFooterBanners(slot) { 260 if (!slot || slot.dataset.cwLoaded === '1') { 261 return; 262 } 263 264 var wantedCount = getWantedCount(); 265 var src = setUrlCount(slot.getAttribute('data-src') || '/partials/footer-banners.php?count=3', wantedCount); 266 slot.dataset.cwLoaded = '1'; 267 slot.dataset.cwCount = String(wantedCount); 268 269 fetch(src, { 270 credentials: 'same-origin', 271 cache: 'no-store' 272 }) 273 .then(function (response) { 274 if (response.status === 204) { 275 return ''; 276 } 277 if (!response.ok) { 278 throw new Error('Footer banners failed'); 279 } 280 return response.text(); 281 }) 282 .then(function (html) { 283 if (!html || !html.trim()) { 284 slot.remove(); 285 return; 286 } 287 288 slot.innerHTML = html; 289 fixAdLinks(slot); 290 runInsertedScripts(slot); 291 292 includeAdScripts(function () { 293 updateRenderer(); 294 setTimeout(updateRenderer, 300); 295 setTimeout(updateRenderer, 1000); 296 }); 297 }) 298 .catch(function () { 299 slot.remove(); 300 }); 301 } 302 303 function reloadIfBreakpointChanged() { 304 var wantedCount = getWantedCount(); 305 306 document.querySelectorAll('[data-cw-footer-banners]').forEach(function (slot) { 307 if (slot.dataset.cwCount === String(wantedCount)) { 308 return; 309 } 310 311 slot.innerHTML = ''; 312 slot.dataset.cwLoaded = '0'; 313 loadFooterBanners(slot); 314 }); 315 } 316
317 function init() { 318 if (initialized) { 319 return; 320 } 321 initialized = true; 322 injectFooterBannerStyles(); 323 document.querySelectorAll('[data-cw-footer-banners]').forEach(loadFooterBanners); 324 325 window.addEventListener('resize', function () { 326 clearTimeout(resizeTimer); 327 resizeTimer = setTimeout(reloadIfBreakpointChanged, RESIZE_DEBOUNCE_MS); 328 }); 329 } 330 331 function loadAfterIdle() { 332 if ('requestIdleCallback' in window) { 333 window.requestIdleCallback(init, { timeout: IDLE_TIMEOUT_MS }); 334 return; 335 } 336 337 window.setTimeout(init, FALLBACK_DELAY_AFTER_LOAD_MS); 338 } 339 340 function scheduleFallback() { 341 window.setTimeout(loadAfterIdle, FALLBACK_DELAY_AFTER_LOAD_MS); 342 } 343 344 function bindUserIntentLoad() { 345 ['pointerdown', 'click', 'touchstart', 'keydown'].forEach(function (eventName) { 346 window.addEventListener(eventName, init, { 347 once: true, 348 passive: true, 349 capture: true 350 }); 351 }); 352 } 353 354 if (document.readyState === 'loading') { 355 document.addEventListener('DOMContentLoaded', function () { 356 bindUserIntentLoad(); 357 window.addEventListener('load', scheduleFallback, { once: true }); 358 }, { once: true }); 359 } else { 360 bindUserIntentLoad(); 361 if (document.readyState === 'complete') { 362 scheduleFallback(); 363 } else { 364 window.addEventListener('load', scheduleFallback, { once: true }); 365 } 366 } 367}());
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.