1(function() { 2 "use strict"; 3 var ADSENSE_SCRIPT_ID = "ua-adsense-loader"; 4 var ADSENSE_SCRIPT_SRC = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"; 5 var adsenseScriptState = "idle"; 6 var adsenseScriptCallbacks = []; 7 var adsenseScriptTimer = null; 8 function setAdBlockCookie(isBlocked) { 9 var value = isBlocked ? "1" : "0"; 10 document.cookie = "adblock_detected=" + value + "; path=/; max-age=31536000; samesite=lax"; 11 } 12 function isElementHidden(el) { 13 if (!el) { 14 return true; 15 } 16 var style = window.getComputedStyle(el); 17 return style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || el.offsetHeight === 0 || el.offsetWidth === 0; 18 } 19 function createKeywordProbe() { 20 var probe = document.createElement("div"); 21 probe.className = "ads ad adsbox ad-placement ad_area ad-unit ad-container ad-banner ads-banner text-ad sponsored support-spot-ad-probe"; 22 document.body.appendChild(probe); 23 return probe; 24 } 25 function getAdSlotsForViewport() { 26 var slots = document.querySelectorAll("ins.adsbygoogle"); 27 return Array.prototype.filter.call(slots, function(slot) { 28 var minWidth = parseInt(slot.getAttribute("data-ad-min-width") || "0", 10); 29 return minWidth <= 0 || window.innerWidth >= minWidth; 30 }); 31 } 32 function getEligibleAdSlots() { 33 return getAdSlotsForViewport().filter(function(slot) { 34 var style = window.getComputedStyle(slot); 35 var rect = slot.getBoundingClientRect(); 36 return style.display !== "none" && style.visibility !== "hidden" && rect.width > 0; 37 }); 38 }
39 function finishAdsenseScriptLoad(state) { 40 if (adsenseScriptState === "loaded") { 41 return; 42 } 43 if (adsenseScriptState === "blocked" && state !== "loaded") { 44 return; 45 } 46 adsenseScriptState = state; 47 if (adsenseScriptTimer) { 48 window.clearTimeout(adsenseScriptTimer); 49 adsenseScriptTimer = null; 50 } 51 var callbacks = adsenseScriptCallbacks.slice(); 52 adsenseScriptCallbacks = []; 53 callbacks.forEach(function(callback) { 54 callback(adsenseScriptState); 55 }); 56 if (state === "loaded" && !callbacks.length) { 57 window.setTimeout(initAdsenseSlots, 0); 58 } 59 } 60 function loadAdsenseScript(callback) { 61 var existingScript = document.getElementById(ADSENSE_SCRIPT_ID); 62 if (adsenseScriptState === "loaded" || adsenseScriptState === "blocked") { 63 callback(adsenseScriptState); 64 return; 65 } 66 adsenseScriptCallbacks.push(callback); 67 if (existingScript || adsenseScriptState === "loading") { 68 return; 69 } 70 adsenseScriptState = "loading"; 71 var script = document.createElement("script"); 72 script.id = ADSENSE_SCRIPT_ID; 73 script.async = true; 74 script.src = ADSENSE_SCRIPT_SRC; 75 script.onload = function() { 76 finishAdsenseScriptLoad("loaded"); 77 }; 78 script.onerror = function() { 79 finishAdsenseScriptLoad("blocked"); 80 }; 81 adsenseScriptTimer = window.setTimeout(function() { 82 finishAdsenseScriptLoad("blocked"); 83 }, 7e3); 84 (document.head || document.documentElement).appendChild(script); 85 } 86 function pushAdSlot(slot) { 87 if (slot.getAttribute("data-ad-initialized") === "1") { 88 return; 89 } 90 slot.setAttribute("data-ad-initialized", "1"); 91 try { 92 (window.adsbygoogle = window.adsbygoogle || []).push({}); 93 } catch (e) { 94 slot.removeAttribute("data-ad-initialized"); 95 } 96 } 97 function initAdsenseSlots() { 98 var slots = getEligibleAdSlots().filter(function(slot) { 99 return slot.getAttribute("data-ad-initialized") !== "1"; 100 }); 101 if (!slots.length) { 102 return; 103 } 104 loadAdsenseScript(function(state) { 105 if (state !== "loaded") { 106 return; 107 } 108 slots.forEach(pushAdSlot); 109 }); 110 } 111 function probeBySlots() { 112 var slots = getAdSlotsForViewport(); 113 if (!slots.length) { 114 return { 115 blocked: false, 116 strongBlocked: false 117 }; 118 } 119 function isBigFrame(frame) { 120 var r = frame.getBoundingClientRect(); 121 return r.width >= 40 && r.height >= 40; 122 } 123 function isTinyFrame(frame) { 124 var r = frame.getBoundingClientRect(); 125 return r.width <= 5 || r.height <= 5; 126 } 127 var hasHealthySlot = false; 128 var hasTinyOnlyFrames = false; 129 var hasHiddenExpectedSlot = false; 130 Array.prototype.forEach.call(slots, function(slot) { 131 var style = window.getComputedStyle(slot); 132 var slotRect = slot.getBoundingClientRect(); 133 if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || slotRect.width === 0) { 134 hasHiddenExpectedSlot = true; 135 return; 136 } 137 var frames = slot.querySelectorAll("iframe"); 138 if (frames.length) { 139 var hasBigFrame = Array.prototype.some.call(frames, isBigFrame); 140 var tinyFrames = Array.prototype.filter.call(frames, isTinyFrame).length; 141 if (hasBigFrame) { 142 hasHealthySlot = true; 143 return; 144 } 145 if (tinyFrames === frames.length) { 146 hasTinyOnlyFrames = true; 147 } 148 } 149 if (slot.getAttribute("data-ad-status") === "filled" && slot.offsetWidth >= 120 && slot.offsetHeight >= 50) { 150 hasHealthySlot = true; 151 return; 152 } 153 if (slot.offsetWidth >= 120 && slot.offsetHeight >= 70) { 154 hasHealthySlot = true; 155 } 156 }); 157 return { 158 blocked: adsenseScriptState === "blocked" || hasHiddenExpectedSlot || !hasHealthySlot, 159 strongBlocked: hasHiddenExpectedSlot || !hasHealthySlot && hasTinyOnlyFrames 160 }; 161 } 162 function detectBlockedMode(callback) { 163 var keywordProbe = createKeywordProbe(); 164 var keywordBlocked = false;
165 var finalized = false; 166 function maybeFinalize() { 167 if (finalized) { 168 return; 169 } 170 finalized = true; 171 var slotCheck = probeBySlots(); 172 var votes = 0; 173 if (keywordBlocked) { 174 votes++; 175 } 176 if (adsenseScriptState === "blocked") { 177 votes++; 178 } 179 if (slotCheck.blocked) { 180 votes++; 181 } 182 var blocked = slotCheck.strongBlocked || votes >= 2 || adsenseScriptState === "blocked" && keywordBlocked; 183 if (keywordProbe.parentNode) { 184 keywordProbe.parentNode.removeChild(keywordProbe); 185 } 186 callback(blocked); 187 } 188 window.setTimeout(function() { 189 keywordBlocked = isElementHidden(keywordProbe); 190 }, 200); 191 window.setTimeout(maybeFinalize, 3400); 192 } 193 function initSupportSpot() { 194 var blockedSpots = document.querySelectorAll(".js-support-spot-blocked"); 195 if (!blockedSpots.length) { 196 return; 197 } 198 var alreadyShown = false; 199 function restoreAdVisibility() { 200 Array.prototype.forEach.call(blockedSpots, function(spot) { 201 var cell = spot.closest(".js-slot-cell"); 202 var adsWrap = cell ? cell.querySelector(".js-slot-core") : null; 203 var row = spot.closest(".row"); 204 spot.hidden = true; 205 if (adsWrap) { 206 adsWrap.classList.remove("is-support-spot-hidden"); 207 } 208 if (row) { 209 row.classList.remove("is-support-spot-hidden"); 210 } 211 }); 212 } 213 function applyBlockedVisibility(isBlocked) { 214 setAdBlockCookie(isBlocked); 215 if (!isBlocked) { 216 if (alreadyShown) { 217 alreadyShown = false; 218 restoreAdVisibility(); 219 } 220 return; 221 } 222 if (alreadyShown) { 223 return; 224 } 225 alreadyShown = true; 226 Array.prototype.forEach.call(blockedSpots, function(spot) { 227 spot.hidden = true; 228 }); 229 var firstShown = false; 230 Array.prototype.forEach.call(blockedSpots, function(spot) { 231 var cell = spot.closest(".js-slot-cell"); 232 var adsWrap = cell ? cell.querySelector(".js-slot-core") : null; 233 var row = spot.closest(".row"); 234 if (!firstShown) { 235 firstShown = true; 236 if (adsWrap) { 237 adsWrap.classList.add("is-support-spot-hidden"); 238 } 239 spot.hidden = false; 240 return; 241 } 242 if (row) { 243 row.classList.add("is-support-spot-hidden"); 244 } else { 245 spot.hidden = true; 246 } 247 }); 248 } 249 function runDetectionWithRetry(delays) { 250 if (!delays.length) { 251 return; 252 } 253 var delay = delays.shift(); 254 window.setTimeout(function() { 255 detectBlockedMode(function(isBlocked) { 256 applyBlockedVisibility(isBlocked); 257 runDetectionWithRetry(delays); 258 }); 259 }, delay); 260 } 261 runDetectionWithRetry([ 0, 900, 1800 ]); 262 } 263 function init() { 264 initAdsenseSlots(); 265 initSupportSpot(); 266 } 267 var resizeTimer = null; 268 function handleResize() { 269 if (resizeTimer) { 270 window.clearTimeout(resizeTimer); 271 } 272 resizeTimer = window.setTimeout(initAdsenseSlots, 200); 273 } 274 if (document.readyState === "loading") { 275 document.addEventListener("DOMContentLoaded", init); 276 } else { 277 init(); 278 } 279 window.addEventListener("resize", handleResize); 280})();
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.