2025-06-09 14:30:03 +08:00

22 lines
685 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// scripts/utils.js
function log(...args) {
const version = chrome?.runtime?.getManifest?.().version || "dev";
console.log("[v" + version + "]", ...args);
}
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function formatLocalTime(ts) {
if (!ts) return "";
const date = new Date(Number(ts));
if (isNaN(date.getTime())) return "";
// 格式2024-06-01 13:47
return date.getFullYear() + "-" +
String(date.getMonth() + 1).padStart(2, "0") + "-" +
String(date.getDate()).padStart(2, "0") + " " +
String(date.getHours()).padStart(2, "0") + ":" +
String(date.getMinutes()).padStart(2, "0");
}