1(function () { 2 "use strict"; 3 4 const SEL = ".live-news-video-views[data-bunny-guid]"; 5 const queue = new Set(); 6 let timer = null; 7 8 function flush() { 9 timer = null; 10 const guids = Array.from(queue); 11 queue.clear(); 12 if (!guids.length) return; 13 14 fetch((window.LNV_BUNNY_VIEWS?.rest || "/wp-json/livenetwork/v1/bunny-views"), { 15 method: "POST", 16 headers: { "Content-Type": "application/json" }, 17 body: JSON.stringify({ guids }) 18 }) 19 .then(r => r.json().catch(() => null)) 20 .then(json => { 21 if (!json || !json.success || !json.items) return; 22 guids.forEach(g => { 23 const v = json.items[g]; 24 if (typeof v !== "number") return; 25 document.querySelectorAll(`${SEL}[data-bunny-guid="${CSS.escape(g)}"] .live-video-views-value`) 26 .forEach(el => { el.textContent = String(v).replace(/\B(?=(\d{3})+(?!\d))/g, "."); }); 27 }); 28 }) 29 .catch(() => {}); 30 } 31 32 function enqueue(guid) { 33 queue.add(guid); 34 if (!timer) timer = setTimeout(flush, 200); // batch micro-debounce 35 } 36 37 function boot() { 38 const els = Array.from(document.querySelectorAll(SEL)); 39 if (!els.length) return; 40 41 const io = new IntersectionObserver((entries) => { 42 entries.forEach((e) => { 43 if (!e.isIntersecting) return; 44 const el = e.target; 45 const guid = el.getAttribute("data-bunny-guid"); 46 if (guid) enqueue(guid); 47 io.unobserve(el); 48 }); 49 }, { rootMargin: "300px 0px" }); 50 51 els.forEach(el => io.observe(el)); 52 } 53 54 if (document.readyState === "loading") { 55 document.addEventListener("DOMContentLoaded", boot); 56 } else { 57 boot(); 58 } 59})();
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.