1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3var lures; 4(function (lures) { 5 function enable() { 6 var isDebugMode = getQueryParam('debugLures') === 'true'; 7 var url = '/lures/render'; 8 var xmlhttp = getXmlHttpRequest(function (response) { 9 if (isDebugMode && response.positionGroups) { 10 renderDebugOverlay(response); 11 return; 12 } 13 var _loop_1 = function (segment) { 14 var isPopup = segment.html.indexOf('overlay') != -1 || 15 segment.html.indexOf('modal') != -1; 16 if (isPopup && window.popupManager && window.popupManager.isPopupActive()) { 17 console.log('segment skipped due to active popup'); 18 } 19 else { 20 if (segment.delay > 0) { 21 setTimeout(function () { 22 renderLure(segment, isPopup, true); 23 }, segment.delay); 24 } 25 else { 26 renderLure(segment, isPopup, false); 27 } 28 } 29 }; 30 for (var _i = 0, response_1 = response; _i < response_1.length; _i++) { 31 var segment = response_1[_i]; 32 _loop_1(segment); 33 } 34 afterRender(); 35 if (response.length > 0) { 36 postMessage("luresRendered"); 37 window.pubbleUtility.disableDoubleClick(); 38 } 39 }); 40 var params = { 41 userAccessLevel: window.lureArticle.userAccessLevel, 42 articlesLeft: window.lureArticle.articlesLeft, 43 articleAccessLevel: window.lureArticle.articleAccessLevel, 44 articleId: window.lureArticle.articleId, 45 pagepath: window.location.pathname, 46 region: window.pubbleEnv.region 47 }; 48 if (window.lureArticle.giftToken) { 49 params.giftToken = window.lureArticle.giftToken; 50 } 51 if (isDebugMode) { 52 params.debug = true; 53 } 54 url = url + '?' + serialize(params); 55 xmlhttp.open("GET", url, true); 56 xmlhttp.send(); 57 } 58 lures.enable = enable; 59 ; 60 function renderLure(segment, isPopup, executeAfterRender) { 61 var element = document.createElement("div"); 62 element.innerHTML = segment.html; 63 element.id = 'segment-' + Math.floor(Math.random() * 10000); 64 if (isPopup && window.popupManager) { 65 window.popupManager.activatePopup(element.id); 66 } 67 if (segment.pagePosition == 0) { 68 document.body.insertBefore(element, document.body.firstChild); 69 } 70 if (segment.pagePosition == 1) { 71 document.body.appendChild(element); 72 } 73 if (segment.pagePosition == 2) { 74 if (!element || !(element instanceof Node)) { 75 console.error('Invalid element to insert'); 76 return; 77 } 78 var articleBody = document.getElementsByClassName('article-body')[0]; 79 if (articleBody) { 80 var pTags = articleBody.getElementsByTagName('p'); 81 if (pTags.length > 1) { 82 try { 83 var referenceNode = pTags[1].nextSibling; 84 if (referenceNode && referenceNode.parentNode === articleBody) { 85 articleBody.insertBefore(element, referenceNode); 86 } 87 else if (pTags[1].parentNode) { 88 pTags[1].parentNode.insertBefore(element, pTags[1].nextSibling); 89 } 90 else { 91 articleBody.appendChild(element); 92 } 93 } 94 catch (e) { 95 console.error('Error inserting element:', e); 96 articleBody.appendChild(element); 97 } 98 } 99 else { 100 articleBody.appendChild(element); 101 } 102 } 103 else { 104 console.error('Article body not found'); 105 } 106 } 107 if (segment.pagePosition == 3 && document.getElementsByTagName('article').length > 0) { 108 var articleSegment = document.getElementsByTagName('article')[0]; 109 articleSegment.appendChild(element); 110 }
111 if (document.getElementById(element.id)) { 112 console.log('child appended'); 113 } 114 if (segment.script && segment.script.length > 1) { 115 eval(segment.script); 116 console.log('segment script executed'); 117 } 118 if (executeAfterRender) { 119 afterRender(); 120 } 121 } 122 function afterRender() { 123 var headlines = document.querySelectorAll("[data-lure-bind='headline']"); 124 headlines.forEach(function (el) { 125 el.innerHTML = window.lureArticle.articleHeadline; 126 }); 127 var scripts = document.querySelectorAll("[data-lure-script]"); 128 scripts.forEach(function (el) { 129 execScript(el.getAttribute("data-lure-script")); 130 }); 131 } 132 function getXmlHttpRequest(callback) { 133 var xmlhttp = new XMLHttpRequest(); 134 xmlhttp.onreadystatechange = function () { 135 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 136 var response = xmlhttp.responseText; 137 if (response.substr(0, 1) == '?') { 138 response = response.replace('??(', ''); 139 response = response.replace('})', '}'); 140 } 141 if (isJson(response) && callback != undefined) { 142 callback(JSON.parse(response)); 143 } 144 else { 145 if (callback != undefined) { 146 return callback(response); 147 } 148 } 149 } 150 }; 151 return xmlhttp; 152 } 153 function serialize(obj, prefix) { 154 if (prefix === void 0) { prefix = null; } 155 var str = [], p; 156 for (p in obj) { 157 if (obj.hasOwnProperty(p)) { 158 var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p]; 159 str.push((v !== null && typeof v === "object") ? 160 serialize(v, k) : 161 encodeURIComponent(k) + "=" + encodeURIComponent(v)); 162 } 163 } 164 return str.join("&"); 165 } 166 function isJson(str) { 167 try { 168 JSON.parse(str); 169 } 170 catch (e) { 171 return false; 172 } 173 return true; 174 } 175 function getQueryParam(name) { 176 var urlParams = new URLSearchParams(window.location.search); 177 return urlParams.get(name); 178 } 179 function renderDebugOverlay(debugData) { 180 var _a, _b; 181 var existingOverlay = document.getElementById('lure-debug-overlay'); 182 if (existingOverlay) { 183 existingOverlay.remove(); 184 } 185 var overlay = document.createElement('div'); 186 overlay.id = 'lure-debug-overlay'; 187 overlay.style.cssText = "\n position: fixed;\n bottom: 20px;\n right: 20px;\n width: 420px;\n max-height: 600px;\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(20px) saturate(180%);\n -webkit-backdrop-filter: blur(20px) saturate(180%);\n border-radius: 16px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;\n font-size: 13px;\n color: #1d1d1f;\n z-index: 999999;\n display: flex;\n flex-direction: column;\n border: 1px solid rgba(0, 0, 0, 0.08);\n "; 188 var header = document.createElement('div'); 189 header.style.cssText = "\n padding: 16px 20px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.08);\n display: flex;\n justify-content: space-between;\n align-items: center;\n background: rgba(247, 247, 247, 0.8);\n border-radius: 16px 16px 0 0;\n "; 190 var title = document.createElement('div'); 191 title.style.cssText = "\n font-size: 15px;\n font-weight: 600;\n letter-spacing: -0.02em;\n "; 192 title.textContent = 'ð£ Lure Debugger'; 193 var closeBtn = document.createElement('button'); 194 closeBtn.innerHTML = 'â'; 195 closeBtn.style.cssText = "\n background: transparent;\n border: none;\n font-size: 18px;\n color: #86868b;\n cursor: pointer;\n padding: 0;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: all 0.2s ease;\n "; 196 closeBtn.onmouseover = function () { 197 closeBtn.style.background = 'rgba(0, 0, 0, 0.05)'; 198 closeBtn.style.color = '#1d1d1f'; 199 }; 200 closeBtn.onmouseout = function () { 201 closeBtn.style.background = 'transparent'; 202 closeBtn.style.color = '#86868b'; 203 }; 204 closeBtn.onclick = function () { return overlay.remove(); }; 205 header.appendChild(title); 206 header.appendChild(closeBtn); 207 var content = document.createElement('div'); 208 content.style.cssText = "\n overflow-y: auto;\n padding: 16px 20px;\n flex: 1;\n "; 209 var summary = document.createElement('div'); 210 summary.style.cssText = "\n margin-bottom: 16px;\n padding: 12px;\n background: rgba(0, 122, 255, 0.08);\n border-radius: 8px;\n font-size: 12px;\n line-height: 1.5;\n "; 211 summary.innerHTML = "\n <div style=\"font-weight: 600; margin-bottom: 4px;\">Summary</div>\n <div>Total Lures: ".concat(debugData.totalLuresEvaluated, "</div>\n <div>Selected: ").concat(((_a = debugData.selectedLures) === null || _a === void 0 ? void 0 : _a.length) || 0, "</div>\n "); 212 content.appendChild(summary); 213 (_b = debugData.positionGroups) === null || _b === void 0 ? void 0 : _b.forEach(function (positionGroup) { 214 var _a; 215 var positionSection = document.createElement('div'); 216 positionSection.style.cssText = "\n margin-bottom: 16px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid rgba(0, 0, 0, 0.08);\n "; 217 var positionHeader = document.createElement('div'); 218 positionHeader.style.cssText = "\n padding: 10px 12px;\n background: rgba(0, 0, 0, 0.03);\n font-weight: 600;\n font-size: 12px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: pointer;\n user-select: none;\n "; 219 var positionName = getPositionName(positionGroup.position); 220 var selectedLure = positionGroup.selectedLure;
221 positionHeader.innerHTML = "\n <span>".concat(positionName, "</span>\n <span style=\"font-weight: 400; color: ").concat(selectedLure ? '#34c759' : '#ff3b30', "; font-size: 11px;\">\n ").concat(selectedLure ? 'â Selected' : 'â None', "\n </span>\n "); 222 var luresList = document.createElement('div'); 223 luresList.style.cssText = "\n display: none;\n "; 224 var isExpanded = false; 225 positionHeader.onclick = function () { 226 isExpanded = !isExpanded; 227 luresList.style.display = isExpanded ? 'block' : 'none'; 228 }; 229 (_a = positionGroup.luresEvaluated) === null || _a === void 0 ? void 0 : _a.forEach(function (lure) { 230 var lureItem = document.createElement('div'); 231 lureItem.style.cssText = "\n padding: 12px;\n border-top: 1px solid rgba(0, 0, 0, 0.05);\n background: ".concat(lure.isSelected ? 'rgba(52, 199, 89, 0.08)' : 'white', ";\n "); 232 var statusColor = '#86868b'; 233 var statusIcon = 'â'; 234 if (lure.isSelected) { 235 statusColor = '#34c759'; 236 statusIcon = 'â'; 237 } 238 else if (lure.passedAllRules && !lure.isSelected) { 239 statusColor = '#ff9500'; 240 statusIcon = 'â'; 241 } 242 else if (!lure.passedAllRules) { 243 statusColor = '#ff3b30'; 244 statusIcon = 'â'; 245 } 246 lureItem.innerHTML = "\n <div style=\"display: flex; justify-content: space-between; align-items: start; margin-bottom: 6px;\">\n <div style=\"font-weight: 600; font-size: 13px; flex: 1;\">\n <span style=\"color: ".concat(statusColor, "; margin-right: 6px;\">").concat(statusIcon, "</span>\n ").concat(lure.lureName || lure.lureId, "\n </div>\n <div style=\"font-size: 11px; color: #86868b; white-space: nowrap; margin-left: 8px;\">\n Order: ").concat(lure.sortOrder, "\n </div>\n </div>\n ").concat(lure.failureReason ? "\n <div style=\"font-size: 11px; color: #86868b; margin-top: 4px; padding-left: 18px;\">\n ".concat(lure.failureReason, "\n </div>\n ") : '', "\n ").concat(lure.ruleResults && lure.ruleResults.length > 0 ? "\n <div style=\"margin-top: 8px; padding-left: 18px;\">\n ".concat(lure.ruleResults.map(function (rule) { return "\n <div style=\"font-size: 11px; margin-bottom: 4px; opacity: 0.8;\">\n <span style=\"color: ".concat(rule.passed ? '#34c759' : '#ff3b30', ";\">\n ").concat(rule.passed ? 'â' : 'â', "\n </span>\n ").concat(rule.description, "\n <div style=\"color: #86868b; margin-left: 16px; margin-top: 2px;\">\n Expected: ").concat(rule.ruleValue, " | Actual: ").concat(rule.actualInputValue, "\n </div>\n </div>\n "); }).join(''), "\n </div>\n ") : '', "\n "); 247 luresList.appendChild(lureItem); 248 }); 249 positionSection.appendChild(positionHeader); 250 positionSection.appendChild(luresList); 251 content.appendChild(positionSection); 252 }); 253 overlay.appendChild(header); 254 overlay.appendChild(content); 255 document.body.appendChild(overlay); 256 } 257 function getPositionName(position) { 258 var positions = ['Page Top', 'Page Bottom', 'Article Inside', 'Article Bottom']; 259 return positions[position] || "Position ".concat(position); 260 } 261 var executedScripts = []; 262 function execScript(src) { 263 if (executedScripts.indexOf(src) != -1) 264 return false;
265 executedScripts.push(src); 266 var data = "", head = document.getElementsByTagName("head")[0] || 267 document.documentElement, script = document.createElement("script"); 268 script.type = "text/javascript"; 269 try { 270 script.appendChild(document.createTextNode(data)); 271 } 272 catch (e) { 273 script.text = data; 274 } 275 script.src = src; 276 head.insertBefore(script, head.firstChild); 277 } 278})(lures || (lures = {})); 279lures.enable(); 280//# sourceMappingURL=lures.js.map
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.