// 监听菜单打开,然后添加社交图标 (function() { let iconsAdded = false; let checkInterval; function stopWatcher() { if (checkInterval) { clearInterval(checkInterval); checkInterval = null; } } function addIcons() { if (iconsAdded) return; setTimeout(() => { const allLinks = Array.from(document.querySelectorAll('a')); const contactLink = allLinks.find(a => a.textContent && a.textContent.trim() === '联系我们'); if (!contactLink) { console.log('社交图标脚本:当前页面无“联系我们”,终止注入'); stopWatcher(); return; } const footer = contactLink.closest('footer'); if (!footer) { console.log('社交图标脚本:未找到 footer,终止注入'); stopWatcher(); return; } if (footer.querySelector('.social-icons-added')) { iconsAdded = true; stopWatcher(); return; } const iconDiv = document.createElement('div'); iconDiv.className = 'social-icons-added'; iconDiv.style.cssText = ` display: flex; justify-content: center; align-items: center; gap: 1.5rem; padding: 2rem 0 1rem 0; width: 100%; `; iconDiv.innerHTML = ` 小红书 抖音 微信 `; footer.appendChild(iconDiv); iconsAdded = true; stopWatcher(); console.log('✓ 社交图标已成功添加'); }, 300); } const menuButton = document.querySelector('[data-motion-hamb]'); if (menuButton) { menuButton.addEventListener('click', () => { addIcons(); setTimeout(addIcons, 500); setTimeout(addIcons, 1000); }); } checkInterval = setInterval(() => { if (iconsAdded) { stopWatcher(); return; } addIcons(); }, 500); })();