if (window.location.pathname.startsWith('/news/')) { const bannerWrapper = document.createElement('div'); bannerWrapper.id = 'mid-article-banner'; fetch('/banner') .then(response => response.text()) .then(html => { const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); const bannerContent = doc.querySelector('main'); if (bannerContent) { bannerWrapper.innerHTML = bannerContent.innerHTML; const blogContent = document.querySelector('.entry-content, article, main, .sqs-block-content'); if (blogContent) { const paragraphs = blogContent.querySelectorAll('p'); let insertAfter = null; for (let i = 0; i < paragraphs.length; i++) { if (paragraphs[i].querySelector('img')) { insertAfter = paragraphs[i].nextElementSibling; break; } } if (!insertAfter) { const midpoint = Math.floor(paragraphs.length / 2); insertAfter = paragraphs[midpoint] || blogContent.lastElementChild; } insertAfter.parentNode.insertBefore(bannerWrapper, insertAfter.nextSibling); } } else { console.warn('No usable content found in /banner'); } }) .catch(error => console.error('Banner fetch failed:', error)); }
SEOTracker