Update and rename tracker.js to tracker-dev.js
This commit is contained in:
parent
44ab3922f1
commit
b8879c238d
@ -1,10 +1,8 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const collectData = async () => {
|
const collectData = async () => {
|
||||||
// 基础信息
|
|
||||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
let osName = 'unknown', osVersion = 'unknown';
|
let osName = 'unknown', osVersion = 'unknown';
|
||||||
|
|
||||||
// 操作系统检测
|
|
||||||
if (navigator.userAgentData) {
|
if (navigator.userAgentData) {
|
||||||
try {
|
try {
|
||||||
const data = await navigator.userAgentData.getHighEntropyValues([
|
const data = await navigator.userAgentData.getHighEntropyValues([
|
||||||
@ -16,13 +14,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
osName = data.platform.toLowerCase();
|
osName = data.platform.toLowerCase();
|
||||||
osVersion = data.platformVersion;
|
osVersion = data.platformVersion;
|
||||||
|
|
||||||
// Windows版本处理
|
|
||||||
if (osName === 'windows') {
|
if (osName === 'windows') {
|
||||||
const majorVer = parseInt(osVersion.split('.')[0]);
|
const majorVer = parseInt(osVersion.split('.')[0]);
|
||||||
osVersion = majorVer >= 13 ? '11' : majorVer > 0 ? '10' : '8.1';
|
osVersion = majorVer >= 13 ? '11' : majorVer > 0 ? '10' : '8.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
// macOS版本转换
|
|
||||||
if (osName === 'macos') {
|
if (osName === 'macos') {
|
||||||
const macVersionMap = {
|
const macVersionMap = {
|
||||||
'13': 'Ventura', '12': 'Monterey',
|
'13': 'Ventura', '12': 'Monterey',
|
||||||
@ -31,17 +27,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
osVersion = macVersionMap[osVersion.split('.')[0]] || osVersion;
|
osVersion = macVersionMap[osVersion.split('.')[0]] || osVersion;
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error('High Entropy API error:', e);
|
// 错误静默处理
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 传统User-Agent分析
|
|
||||||
const ua = navigator.userAgent;
|
const ua = navigator.userAgent;
|
||||||
if (/Windows NT 10/.test(ua)) osName = 'windows', osVersion = '10';
|
if (/Windows NT 10/.test(ua)) osName = 'windows', osVersion = '10';
|
||||||
if (/Mac OS X 10_15/.test(ua)) osName = 'macos', osVersion = 'Catalina';
|
if (/Mac OS X 10_15/.test(ua)) osName = 'macos', osVersion = 'Catalina';
|
||||||
if (/iPhone OS 16_/.test(ua)) osName = 'ios', osVersion = '16';
|
if (/iPhone OS 16_/.test(ua)) osName = 'ios', osVersion = '16';
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPU架构检测
|
|
||||||
let cpuArch = 'unknown';
|
let cpuArch = 'unknown';
|
||||||
if (navigator.userAgentData?.architecture) {
|
if (navigator.userAgentData?.architecture) {
|
||||||
cpuArch = navigator.userAgentData.architecture;
|
cpuArch = navigator.userAgentData.architecture;
|
||||||
@ -50,7 +44,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
/arm|aarch64/i.test(navigator.userAgent) ? 'arm' : 'x86';
|
/arm|aarch64/i.test(navigator.userAgent) ? 'arm' : 'x86';
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPU检测
|
|
||||||
let gpuVendor = 'unknown', gpuModel = 'unknown';
|
let gpuVendor = 'unknown', gpuModel = 'unknown';
|
||||||
try {
|
try {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
@ -61,18 +54,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
gpuModel = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
|
gpuModel = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error('GPU detection failed:', e);
|
// 错误静默处理
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送数据
|
fetch(hardwareTrackerDev.ajax_url, {
|
||||||
fetch(hardwareTracker.ajax_url, {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
action: 'hardware_tracker',
|
action: 'hardware_tracker_dev',
|
||||||
security: hardwareTracker.security,
|
security: hardwareTrackerDev.security,
|
||||||
os_name: osName,
|
os_name: osName,
|
||||||
os_version: osVersion,
|
os_version: osVersion,
|
||||||
cpu_arch: cpuArch,
|
cpu_arch: cpuArch,
|
||||||
@ -84,6 +76,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 延迟2秒执行避免影响首屏加载
|
setTimeout(collectData, 300);
|
||||||
collectData();
|
# 延迟300ms错开稳定版
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user