// 修复所有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 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 = '
';
}
// 同时隐藏任何包含"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 = `