Files
tvbox_collect/tvbox/js/index.min.js
T
2026-06-29 03:41:14 +00:00

62 lines
1.5 KiB
JavaScript
Executable File

const currentDomain = window.location.origin;
async function dl(fileUrl, filename) {
try {
const response = await fetch(fileUrl);
if (!response.ok)
throw new Error(`HTTP 错误: ${response.status}`);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => URL.revokeObjectURL(url), 100);
} catch (error) {
console.error('下载错误:', error);
}
}
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;
}
function gh(path) {
const baseUrl = "https://gh.clun.top/raw.githubusercontent.com/FongMi/Release/refs/heads/";
if (path) {
window.open(baseUrl + path, '_blank');
}
}
$(document).ready(function() {
var timeLoad = performance.now();
$("#time").text("页面加载耗时 " + Math.round(timeLoad) + " 毫秒");
getip().then(function(ipData) {
if (ipData) {
$("#cfs").text(ipData);
} else {
$("#cfs").text("获取失败");
}
});
});