From 14612e281e7562986b990e076183f014e842a093 Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Sun, 31 May 2026 19:26:33 +1000 Subject: [PATCH] update oauth expired modal --- index.html | 33 ++++++++++++++++++++++++++ scripts/index.js | 29 ++++++++++++++++++++++- styles/taskList.css | 57 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 117 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 9ffd920..47123a2 100644 --- a/index.html +++ b/index.html @@ -47,5 +47,38 @@
+ + diff --git a/scripts/index.js b/scripts/index.js index 668ea54..be365a3 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -44,4 +44,31 @@ const oauth_token = auth.oauth.includes("oauth:") : `oauth:${auth.oauth}`; const auth_username = auth.username ? auth.username : auth.channel; -ComfyJS.Init(auth_username, `${oauth_token}`, [auth.channel]); +function showOAuthExpiredModal() { + const modal = document.getElementById("oauth-expired-modal"); + if (modal) modal.classList.remove("hidden"); +} + +async function validateOAuthToken() { + const bareToken = oauth_token.replace(/^oauth:/i, ""); + const response = await fetch("https://id.twitch.tv/oauth2/validate", { + headers: { Authorization: `OAuth ${bareToken}` }, + }); + return response.ok; +} + +async function initChat() { + try { + const valid = await validateOAuthToken(); + if (!valid) { + showOAuthExpiredModal(); + return; + } + } catch (err) { + console.warn("Could not validate OAuth token; connecting anyway.", err); + } + + ComfyJS.Init(auth_username, oauth_token, [auth.channel]); +} + +initChat(); diff --git a/styles/taskList.css b/styles/taskList.css index 1e41e90..7afab16 100644 --- a/styles/taskList.css +++ b/styles/taskList.css @@ -167,4 +167,59 @@ width: -moz-fit-content; width: fit-content; margin-left: calc(var(--focus-task-horizontal-padding) * -1); -}/*# sourceMappingURL=taskList.css.map */ \ No newline at end of file +}/*# sourceMappingURL=taskList.css.map */ +.oauth-modal { + position: fixed; + inset: 0; + z-index: 10000; + display: flex; + align-items: center; + justify-content: center; + padding: 1.5rem; + background: rgba(0, 0, 0, 0.75); +} + +.oauth-modal.hidden { + display: none; +} + +.oauth-modal__content { + max-width: 28rem; + padding: 1.5rem 1.75rem; + border-radius: 0.5rem; + background: #18181b; + color: #efeff1; + font-family: system-ui, -apple-system, Segoe UI, sans-serif; + font-size: 0.95rem; + line-height: 1.5; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); +} + +.oauth-modal__content h2 { + margin-bottom: 0.75rem; + font-size: 1.15rem; + font-weight: 600; +} + +.oauth-modal__content p { + margin-bottom: 0.75rem; +} + +.oauth-modal__content ol { + margin-left: 1.25rem; +} + +.oauth-modal__content li + li { + margin-top: 0.35rem; +} + +.oauth-modal__content a { + color: #9147ff; +} + +.oauth-modal__content code { + padding: 0.1em 0.35em; + border-radius: 0.2rem; + background: rgba(255, 255, 255, 0.1); + font-size: 0.9em; +}