add official Chrome feature demos

This commit is contained in:
2026-06-14 15:22:32 +08:00
parent 500217f2fd
commit de690f85fa
32 changed files with 2376 additions and 567 deletions
+24
View File
@@ -0,0 +1,24 @@
export function logTo(target, title, payload) {
const el = typeof target === "string" ? document.querySelector(target) : target;
if (!el) return;
const stamp = new Date().toLocaleTimeString("zh-CN", { hour12: false });
const entry = {
time: stamp,
event: title,
...payload,
};
el.textContent = `${JSON.stringify(entry, null, 2)}\n\n${el.textContent}`.trim();
}
export function setText(selector, value) {
const el = document.querySelector(selector);
if (el) el.textContent = value;
}
export function escapeHtml(value) {
return String(value)
.replaceAll("&", "&")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll('"', "&quot;");
}