-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcftiwo.min.js
1 lines (1 loc) · 1.23 KB
/
cftiwo.min.js
1
async function f(){try{const t=await fetch("/cdn-cgi/trace");if(!t.ok)throw new Error("Failed to fetch Cloudflare trace data");const e=await t.text();return Object.fromEntries(e.trim().split("\n").map((t=>t.split("="))))}catch(t){console.error("Unexpected FFCTD error: ",t)}}async function fi(t,e){try{const a=await fetch(`https://iata.isteed.cc/${e}/${t.substring(0,3)}`);if(!a.ok)throw new Error("Failed to fetch IATA data");return a.text()}catch(t){return console.error("Unexpected FID error: ",t),navigator.language.includes("zh")?"未知":"Unknown"}}async function d(){const t=document.querySelectorAll(".cloudflare-trace-info");if(!t.length)return;const e=navigator.language.includes("zh")?"zh":"en";try{const a=await f(),r=Array.from(t).map((async t=>{const r=t.hasAttribute("data-hide-ip"),n=t.hasAttribute("data-hide-loc");let c=t.getAttribute("data-template");if(c?Object.entries(a).forEach((([t,e])=>{c=c.replace(new RegExp(`\\$\\{${t}\\}`,"g"),e||"")})):c=`[${a.colo}]\${iata}${r?"":` · ${a.ip}`}${n?"":` · ${a.loc}`}`,c.includes("${iata}")){const t=await fi(a.colo,e);c=c.replace("${iata}",t||"")}t.innerHTML=c.trim()}));await Promise.all(r)}catch(t){console.error("Unexpected DISPLAY error: ",t)}}document.addEventListener("DOMContentLoaded",d);