From 85d7fb8705eeb5e37a36759e4bf40ee94b73d20c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Apr 2026 09:11:18 +0000 Subject: [PATCH 1/2] fix: remove beforeunload receipt popup and improve share UX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove beforeunload handler that tried to show receipt modal on page leave — browsers block custom modals in beforeunload, causing a broken native dialog instead - Update openSharePopup to use navigator.share (native OS share sheet on mobile/modern browsers) with Twitter fallback - Rename receipt "Share Receipt" → "Share" and "Copy Text" → "Copy Receipt" for cleaner UX Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/df71b0f3-a0c9-4299-8b2a-2a6efa44cb60 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- index.html | 4 ++-- script.js | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 9b26665..fa9a547 100644 --- a/index.html +++ b/index.html @@ -303,8 +303,8 @@

🏆 Your Doom Badges

Session Receipt


     
- - + +
diff --git a/script.js b/script.js index b773c7d..61c87c1 100644 --- a/script.js +++ b/script.js @@ -855,6 +855,14 @@ } function openSharePopup(text) { + if (navigator.share) { + navigator.share({ text, url: SITE_URL }).catch(() => { + // User cancelled or share failed — fall back to Twitter + const twitterUrl = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(text); + window.open(twitterUrl, '_blank', 'noopener,noreferrer,width=560,height=420'); + }); + return; + } const url = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(text); window.open(url, '_blank', 'noopener,noreferrer,width=560,height=420'); } @@ -1077,10 +1085,10 @@ const text = bodyEl ? bodyEl.textContent : generateReceiptText(); navigator.clipboard.writeText(text).then(() => { copyBtn.textContent = '✅ Copied!'; - setTimeout(() => { copyBtn.textContent = '📋 Copy Text'; }, 2000); + setTimeout(() => { copyBtn.textContent = '📋 Copy Receipt'; }, 2000); }).catch(() => { copyBtn.textContent = '❌ Failed'; - setTimeout(() => { copyBtn.textContent = '📋 Copy Text'; }, 2000); + setTimeout(() => { copyBtn.textContent = '📋 Copy Receipt'; }, 2000); }); }); } @@ -1093,15 +1101,6 @@ }); } - // Offer receipt on beforeunload if session was meaningful - window.addEventListener('beforeunload', (e) => { - const elapsed = Math.floor((Date.now() - pageLoadTime) / 1000); - if (elapsed >= 15 && !receiptShown) { - showReceiptModal(); - e.preventDefault(); - e.returnValue = ''; - } - }); } // ---- Personal Footprint Calculator -------------------------- From 1d9d240bb547eb359120114df4fa4e6c5b962b9b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Apr 2026 09:27:06 +0000 Subject: [PATCH 2/2] fix: enforce [hidden] in CSS reset to prevent modal showing on page load CSS `display: flex` on `.modal-overlay` and `.share-doom-panel` was overriding the browser's user-agent `[hidden] { display: none }` rule (author stylesheets have higher priority than UA stylesheets). This caused the receipt modal to render as a full-screen overlay the moment the page loaded, blocking all content. Adding `[hidden] { display: none !important; }` in the CSS reset section enforces the semantic meaning of the HTML `hidden` attribute regardless of what display value a class sets. Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/51461cef-791a-4bae-b565-79a3dd0840d9 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- styles.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/styles.css b/styles.css index bc77e48..18377e4 100644 --- a/styles.css +++ b/styles.css @@ -51,6 +51,9 @@ /* ---- Reset & Base ---- */ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } +/* Enforce [hidden] even when a class sets an explicit display value */ +[hidden] { display: none !important; } + html { scroll-behavior: smooth; } body {