Update capture_gamertag.js

This commit is contained in:
XXhaos
2026-04-18 13:14:03 +08:00
committed by GitHub
parent 6852b2fd5f
commit d128ac6445

View File

@@ -19,7 +19,7 @@
const peoplePattern = /^https:\/\/peoplehub-public\.xboxlive\.com\/people\/gt\(.+\)/;
const url = $request.url;
const MAX_RECORDS = 20; // gamertag 记录保留最近 20 条
const MAX_RECORDS = 10; // gamertag 记录保留最近 20 条
if (peoplePattern.test(url)) {
if (!$response.body) {
@@ -65,15 +65,6 @@ function appendGamertagRecord(entry) {
} catch (e) { records = []; }
}
// 相邻去重:如果最后一条就是同一个 gamertag只更新它的 ts不新增
// 这样反复刷新同账号不会产生大量冗余记录
if (records.length > 0 && records[records.length - 1].gamertag === entry.gamertag) {
records[records.length - 1].ts = entry.ts;
$persistentStore.write(JSON.stringify(records), "gamertag_records");
console.log(`[gamertag] 更新末条时间戳: ${entry.gamertag}`);
return;
}
records.push(entry);
if (records.length > MAX_RECORDS) records = records.slice(-MAX_RECORDS);
$persistentStore.write(JSON.stringify(records), "gamertag_records");