diff --git a/_worker.js b/_worker.js index c004a1aa3..9a5761746 100644 --- a/_worker.js +++ b/_worker.js @@ -5635,21 +5635,18 @@ async function renderHomePage(request, env, proxySettings, isPassSet) { IP Country City - ISP Cloudflare CDN - ${request.headers.get("cf-connecting-ip") || "-"} - ${cfCountry || "-"} - ${request.cf.city || "-"} - ${request.cf.asOrganization.toUpperCase() || "-"} + + + Others - @@ -5790,22 +5787,26 @@ async function renderHomePage(request, env, proxySettings, isPassSet) { }); const fetchIPInfo = async () => { - const updateUI = (ip = '-', country = '-', country_code = '-', city = '-', isp = '-') => { - const flag = String.fromCodePoint(...[...country_code].map(c => 0x1F1E6 + c.charCodeAt(0) - 65)); - document.getElementById('ip').textContent = ip; - document.getElementById('country').textContent = country + ' ' + flag; - document.getElementById('city').textContent = city; - document.getElementById('isp').textContent = isp.toUpperCase(); + const updateUI = (ip = '-', country = '-', country_code = '-', city = '-', cfIP) => { + const flag = country_code !== '-' ? String.fromCodePoint(...[...country_code].map(c => 0x1F1E6 + c.charCodeAt(0) - 65)) : ''; + document.getElementById(cfIP ? 'cf-ip' : 'ip').textContent = ip; + document.getElementById(cfIP ? 'cf-country' : 'country').textContent = country + ' ' + flag; + document.getElementById(cfIP ? 'cf-city' : 'city').textContent = city; }; - try { - const response = await fetch('https://ipwho.is/'); - const { ip, country, country_code, city, connection } = await response.json(); - updateUI(ip, country, country_code, city, connection.isp); - } catch (error) { - console.error('Error fetching IP address:', error); - updateUI(); + const fetchIPApi = async (cfIP) => { + try { + const response = await fetch('https://ipwho.is/' + cfIP + '?nocache=' + Date.now(), { cache: "no-store" }); + const { ip, country, country_code, city } = await response.json(); + updateUI(ip, country, country_code, city, cfIP); + } catch (error) { + console.error('Error fetching IP address:', error); + updateUI(); + } } + + await fetchIPApi(''); + await fetchIPApi('${request.headers.get("cf-connecting-ip") || "-"}'); } const getWarpConfigs = async () => {