1/*window.addEventListener('DOMContentLoaded', () => { 2 const el = document.getElementById('textbd'); 3 if (!el || typeof marked === 'undefined' || typeof DOMPurify === 'undefined') { 4 console.error('marked ou DOMPurify não estão disponÃveis'); 5 return; 6 } 7 8 const rawText = el.textContent.trim(); 9 const temMarkdown = /[#*_`>-]/.test(rawText); 10 11 if (temMarkdown) { 12 const html = marked.parse(rawText); 13 const clean = DOMPurify.sanitize(html); 14 el.innerHTML = clean; 15 16 // Ajuste de imagens 17 const imgs = el.querySelectorAll('img'); 18 imgs.forEach(img => { 19 img.style.maxWidth = '100%'; 20 img.style.height = 'auto'; 21 img.style.display = 'block'; 22 img.style.margin = '10px 0'; 23 }); 24 } 25 });*/ 26 27 window.addEventListener('DOMContentLoaded', () => { 28 const el = document.getElementById('textbd'); 29 if (!el || typeof marked === 'undefined' || typeof DOMPurify === 'undefined') { 30 console.error('marked ou DOMPurify não estão disponÃveis'); 31 return; 32 } 33 34 const rawText = el.textContent.trim(); 35 const temMarkdown = /[#*_`>-]/.test(rawText); 36 37 if (temMarkdown) { 38 // Permite HTML no Markdown 39 marked.setOptions({ 40 gfm: true, 41 breaks: true, 42 headerIds: false, 43 mangle: false, 44 // â ï¸ IMPORTANTE: não sanitize aqui, pois usaremos DOMPurify abaixo 45 }); 46 47 const html = marked.parse(rawText); 48 49 // Aqui você pode deixar DOMPurify "mais permissivo": 50 const clean = DOMPurify.sanitize(html, { 51 ADD_TAGS: ['script', 'ins'], 52 ADD_ATTR: ['data-ad-client', 'data-ad-slot', 'data-ad-format', 'data-full-width-responsive', 'style', 'async'] 53 }); 54 55 el.innerHTML = clean; 56 57 // Reexecuta scripts injetados (DOMPurify os neutraliza) 58 el.querySelectorAll("script").forEach((oldScript) => { 59 const newScript = document.createElement("script"); 60 Array.from(oldScript.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value)); 61 newScript.text = oldScript.textContent; 62 oldScript.replaceWith(newScript); 63 }); 64 65 // Ajuste de imagens 66 const imgs = el.querySelectorAll('img'); 67 imgs.forEach(img => { 68 img.style.maxWidth = '100%'; 69 img.style.height = 'auto'; 70 img.style.display = 'block'; 71 img.style.margin = '10px 0'; 72 }); 73 } 74 }); 75
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.