// 修复所有logo - 包括加载页面 (function() { let attempts = 0; const maxAttempts = 100; // 将 createLogoImage 和 replaceTextLogos 移到外层,以便 MutationObserver 可以访问 const createLogoImage = (customHeight) => { const img = document.createElement('img'); img.src = '/icon/17 betterlogo.svg'; img.alt = '17 Better AI'; // 使用1em来匹配当前文本行高,如果指定了自定义高度则使用自定义高度 img.style.height = customHeight || '1em'; img.style.width = 'auto'; img.style.verticalAlign = 'middle'; img.dataset.brandLogo = '17better'; return img; }; const replaceTextLogos = () => { if (!document.body) return; const walker = document.createTreeWalker( document.body, NodeFilter.SHOW_TEXT, { acceptNode(node) { if (!node.parentElement) return NodeFilter.FILTER_REJECT; const tag = node.parentElement.tagName; if (['SCRIPT', 'STYLE', 'NOSCRIPT'].includes(tag)) { return NodeFilter.FILTER_REJECT; } return /8bit\.ai/i.test(node.textContent || '') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; } } ); const nodesToReplace = []; let currentNode; while ((currentNode = walker.nextNode())) { nodesToReplace.push(currentNode); } nodesToReplace.forEach(node => { const parent = node.parentNode; if (!parent) return; const parts = node.textContent.split(/8bit\.ai/i); const frag = document.createDocumentFragment(); // 计算父元素的行高作为logo高度 const computedStyle = window.getComputedStyle(parent); const lineHeight = computedStyle.lineHeight; const fontSize = computedStyle.fontSize; // 如果lineHeight是'normal',使用fontSize的1.2倍作为高度 const logoHeight = lineHeight === 'normal' ? `calc(${fontSize} * 1.2)` : lineHeight; parts.forEach((part, index) => { if (part) { frag.appendChild(document.createTextNode(part)); } if (index < parts.length - 1) { frag.appendChild(createLogoImage(logoHeight)); } }); parent.replaceChild(frag, node); }); }; const fixLogos = setInterval(function() { attempts++; // 1. 修复顶部logo const logoContainer = document.querySelector('.z-logo a'); if (logoContainer && !logoContainer.querySelector('img[src*="17 betterlogo"]')) { logoContainer.innerHTML = '17 Better AI17 Better AI'; } // 2. 修复加载页面的logo - 查找.z-loader下的所有内容 const loader = document.querySelector('.z-loader'); if (loader) { // 查找所有文字节点和元素 const loaderContent = loader.querySelector('div'); if (loaderContent) { // 清空并替换为图片 - 使用1.7rem与header保持一致 loaderContent.innerHTML = '17 Better AI'; } // 同时隐藏任何包含"8bit"的文字 const allElements = loader.querySelectorAll('*'); allElements.forEach(el => { if (el.textContent && el.textContent.includes('8bit')) { el.textContent = ''; el.style.display = 'none'; } }); } // 3. 确保社交图标显示 const socialIcons = document.querySelectorAll('[data-motion-social] img'); if (socialIcons.length === 0) { const socialContainer = document.querySelector('[data-motion-social]')?.parentElement; if (socialContainer) { socialContainer.innerHTML = `
  • 小红书
  • 抖音
  • 微信
  • `; } } // 4. 在菜单底部添加社交图标 const menuBottomArea = document.querySelector('.z-footer'); if (menuBottomArea) { // 查找"联系我们"后面的区域 const contactsLink = Array.from(document.querySelectorAll('a')).find(a => a.textContent.includes('联系我们')); if (contactsLink) { const parent = contactsLink.closest('footer') || contactsLink.closest('div'); if (parent && !parent.querySelector('.menu-social-icons')) { const socialDiv = document.createElement('div'); socialDiv.className = 'menu-social-icons'; socialDiv.style.cssText = 'display: flex; gap: 1.5rem; margin-top: 2rem; justify-content: center;'; socialDiv.innerHTML = ` 小红书 抖音 微信 `; parent.appendChild(socialDiv); } } } replaceTextLogos(); if (attempts >= maxAttempts) { clearInterval(fixLogos); } }, 50); // 监听 React/Next Hydration 造成的 DOM 变动,及时替换“8bit.ai” const observer = new MutationObserver(() => replaceTextLogos()); const startObserver = () => { if (!document.body) return; observer.observe(document.body, { childList: true, subtree: true, characterData: true }); }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', startObserver, { once: true }); } else { startObserver(); } })();