') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix(ui): transactions table time column shows precise local time (rant 2026-08-24T12:38:44) by argszero · Pull Request #139 · argszero/aitokenpool · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ui/index.html
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AITokenPool</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%234ecdc4'/%3E%3Cstop offset='1' stop-color='%232a9d8f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='64' height='64' rx='14' fill='url(%23g)'/%3E%3Ctext x='32' y='43' font-family='-apple-system,Segoe UI,Arial,sans-serif' font-size='30' font-weight='800' text-anchor='middle' fill='%23062021'%3EAT%3C/text%3E%3C/svg%3E">
<link rel="stylesheet" href="css/style.css?v=20260824-6">
<link rel="stylesheet" href="css/style.css?v=20260824-7">
</head>
<body>

Expand DownExpand Up@@ -683,9 +683,9 @@ <h3 id="chat-title">使用模型</h3>
</div>
</div>

<script src="js/api.js?v=20260824-6"></script>
<script src="js/data.js?v=20260824-6"></script>
<script src="js/i18n.js?v=20260824-6"></script>
<script src="js/app.js?v=20260824-6"></script>
<script src="js/api.js?v=20260824-7"></script>
<script src="js/data.js?v=20260824-7"></script>
<script src="js/i18n.js?v=20260824-7"></script>
<script src="js/app.js?v=20260824-7"></script>
</body>
</html>
32 changes: 29 additions & 3 deletions ui/js/app.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -1171,7 +1171,7 @@

const TX_COLUMNS = [
// rant 2026-08-23T16:01:07:列表内移除 time 列筛选(外部 tx-range 已有时间段筛选,两套并存冗余)
{ key: "time", title: () => T("tx.col.time"), sort: "string", render: (t) => timeCell(t.time) },
{ key: "time", title: () => T("tx.col.time"), sort: "string", render: (t) => timeCell(t.time, true) },
{ key: "type", title: () => T("tx.col.type"), sort: "string", filter: "select",
options: () => ["consume", "earn", "topup", "withdraw", "gift"].map(txType),
filterVal: (t) => txType(t.type),
Expand DownExpand Up@@ -2432,8 +2432,30 @@
return full;
}

// 时间单元格:相对时间展示 + title 悬停显示本地化绝对时间(rant 2026-08-19T20:45:32)
function timeCell(s) {
// 精确本地时间(YYYY-MM-DD HH:MM:SS,到秒)——交易列表时间列(rant 2026-08-24T12:38:44)
function fmtPrecise(s) {
if (!s) return "";
const t = String(s);
const p2 = (x) => String(x).padStart(2, "0");
let m = t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?Z$/);
let d = null;
if (m) {
d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +(m[6] || 0)));
} else {
// 旧后端格式 'YYYY-MM-DD[ HH:MM[:SS]]' → 视为 UTC(同 timeAgo 口径)
m = t.match(/^(\d{4})-(\d{2})-(\d{2})(?:\s+(\d{2}):(\d{2})(?::(\d{2}))?)?$/);
if (m) d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], +(m[4] || 0), +(m[5] || 0), +(m[6] || 0)));
}
if (d && !isNaN(d.getTime())) {
return d.getFullYear() + "-" + p2(d.getMonth() + 1) + "-" + p2(d.getDate()) +
" " + p2(d.getHours()) + ":" + p2(d.getMinutes()) + ":" + p2(d.getSeconds());
}
return t; // 非标准格式(游客 mock 'MM-DD HH:mm' 等)原样返回
}

// 时间单元格:precise=true → 精确本地时间为主文本、相对时间入 title(交易列表,rant 2026-08-24T12:38:44);
// 默认 → 相对时间为主文本、title 悬停显示本地化绝对时间(rant 2026-08-19T20:45:32)
function timeCell(s, precise) {
if (!s) return "";
const t = String(s);
const iso = /^(\d{4})-(\d{2})-(\d{2})[T ]/.test(t);
Expand All@@ -2442,6 +2464,10 @@
const d = new Date(iso && t.includes("T") ? t : t.replace(" ", "T") + "Z");
if (!isNaN(d.getTime())) title = d.toLocaleString();
}
if (precise) {
const rel = timeAgo(s);
return '<span class="timeago" title="' + esc(rel) + '">' + esc(fmtPrecise(s)) + "</span>";
}
return '<span class="timeago" title="' + esc(title) + '">' + esc(timeAgo(s)) + "</span>";
}

Expand Down
Loading