Skip to content

Commit 070f352

Browse files
committed
Update close button on banner to set the timestamp
1 parent 30e5246 commit 070f352

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

public/banner.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
// ── Close button ────────────────────────────────────────────────────
9898
var showClose = params.hidebutton !== "off";
9999
var storageKey = "kao-banner-hidden";
100+
var dismissDays = 30;
100101

101102
// ── Inject CSS ────────────────────────────────────────────────────────
102103
var cssNormal =
@@ -176,10 +177,17 @@
176177
style.textContent = (size === "mini" ? cssMini : cssNormal) + cssCommon;
177178
document.head.appendChild(style);
178179

179-
// ── Check if previously dismissed ────────────────────────────────────
180-
try {
181-
if (localStorage.getItem(storageKey)) return;
182-
} catch (e) {}
180+
// ── Check if previously dismissed (reappears after dismissDays) ─────
181+
if (showClose) {
182+
try {
183+
var dismissed = localStorage.getItem(storageKey);
184+
if (dismissed) {
185+
var elapsed = Date.now() - Number(dismissed);
186+
if (elapsed < dismissDays * 24 * 60 * 60 * 1000) return;
187+
localStorage.removeItem(storageKey);
188+
}
189+
} catch (e) {}
190+
}
183191

184192
// ── Create banner DOM ─────────────────────────────────────────────────
185193
var banner = document.createElement("div");
@@ -212,7 +220,7 @@
212220
closeBtn.textContent = "\u2715";
213221
closeBtn.addEventListener("click", function () {
214222
banner.style.display = "none";
215-
try { localStorage.setItem(storageKey, "1"); } catch (e) {}
223+
try { localStorage.setItem(storageKey, String(Date.now())); } catch (e) {}
216224
});
217225
banner.appendChild(closeBtn);
218226
}

0 commit comments

Comments
 (0)