35 lines
839 B
JavaScript
Executable File
35 lines
839 B
JavaScript
Executable File
const currentDomain = window.location.origin;
|
|
|
|
async function getip() {
|
|
try {
|
|
const response = await fetch("/cdn-cgi/trace");
|
|
if (response.ok) {
|
|
const data = await response.text();
|
|
const lines = data.split("\n");
|
|
const info = {};
|
|
lines.forEach((line) => {
|
|
const parts = line.split("=");
|
|
if (parts.length === 2) {
|
|
info[parts[0]] = parts[1];
|
|
}
|
|
});
|
|
return `${info.loc} ${info.ip} | ${info.colo} | ${info.http} | ${info.tls} | ${info.kex}`;
|
|
}
|
|
} catch (error) {
|
|
console.error("获取失败: ", error);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
var timeLoad = performance.now();
|
|
$("#time").text("页面加载耗时 " + Math.round(timeLoad) + " 毫秒");
|
|
|
|
getip().then(function(ipData) {
|
|
if (ipData) {
|
|
$("#cfs").text(ipData);
|
|
} else {
|
|
$("#cfs").text("获取失败");
|
|
}
|
|
});
|
|
}); |