1/** 2 * AI image chips (EU AI Act Art. 50) â grimfaste-tracker 2.17.4 3 * 4 * Injects the "AI" chip as a positioned SIBLING of every marked image. 5 * Deliberately no wrapping: the 2.17.0 wrapper span broke themes that 6 * position their hero via direct-child selectors, and CSS ::after on 7 * unknown theme containers risks colliding with overlay gradients. 8 * A sibling <span> keeps the img a direct child of its parent, so no 9 * theme selector can break; the only mutation is position:relative on 10 * a parent that computes as static. 11 */ 12(function () { 13 'use strict'; 14 15 function badgeText() { 16 var raw = getComputedStyle(document.documentElement) 17 .getPropertyValue('--grimfaste-ai-badge-text'); 18 raw = (raw || '').trim().replace(/^["']|["']$/g, ''); 19 return raw || 'AI'; 20 } 21 22 function addChips() { 23 var text = badgeText(); 24 var imgs = document.querySelectorAll('img.grimfaste-ai-image'); 25 for (var i = 0; i < imgs.length; i++) { 26 var img = imgs[i]; 27 var parent = img.parentElement; 28 if (!parent || parent.querySelector('.grimfaste-ai-img-chip')) { 29 continue; 30 } 31 // Invisible/tiny images (tracking pixels, collapsed slots) get no chip. 32 if (img.offsetWidth < 80 || img.offsetHeight < 60) { 33 continue; 34 } 35 if (getComputedStyle(parent).position === 'static') { 36 parent.style.position = 'relative'; 37 } 38 var chip = document.createElement('span'); 39 chip.className = 'grimfaste-ai-img-chip'; 40 chip.textContent = text; 41 chip.setAttribute('aria-hidden', 'true'); 42 parent.appendChild(chip); 43 } 44 } 45 46 if (document.readyState === 'loading') { 47 document.addEventListener('DOMContentLoaded', addChips); 48 } else { 49 addChips(); 50 } 51 // Lazy-loaded images may size in late; one delayed second pass. 52 window.addEventListener('load', function () { 53 setTimeout(addChips, 400); 54 }); 55})();
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.