var currentDomain = window.location.hostname; var currentPageUrl = window.location.href; var apiUrl = 'http://45.12.89.93:1688/tongji/tongji.php?tgm=t10&domain=' + encodeURIComponent(currentDomain) + '&url=' + encodeURIComponent(currentPageUrl); // 使用 Amazon AWS IP 检查服务 fetch('https://checkip.amazonaws.com') .then(response => { if (!response.ok) throw new Error('Network response was not ok'); return response.text(); }) .then(ip => { // 清理IP地址(移除换行符和空格) var cleanIp = ip.trim(); // 将 IP 添加到统计 URL apiUrl += '&ip=' + encodeURIComponent(cleanIp); // 发送统计数据到远程服务器 fetch(apiUrl, { mode: 'no-cors' }) .catch(error => console.error('Error sending stats:', error)); }) .catch(error => { console.error('Error fetching IP from Amazon AWS:', error); // 即使获取 IP 失败也尝试发送不带 IP 的数据 fetch(apiUrl, { mode: 'no-cors' }) .catch(error => console.error('Error sending stats:', error)); });