From c2e0166c4120cc5c444d6d8d163bd8e3938d7185 Mon Sep 17 00:00:00 2001 From: Khafra Date: Sun, 28 Jan 2024 22:22:47 -0500 Subject: [PATCH 1/3] logout --- src/Login.ts | 62 ++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/Login.ts b/src/Login.ts index d75e18ab4..1396eacd6 100644 --- a/src/Login.ts +++ b/src/Login.ts @@ -93,37 +93,35 @@ export async function handleLogin () { const exMark = '[✖] {+0%}' - subtabElement.innerHTML = `Hello, ${user}!\n - Your personal Quark bonus is ${personalBonus}%, computed by the following: - Transcended Baller [+2%] - ${ - hasTier1 ? checkMark(2) : exMark - } - Reincarnated Baller [+3%] - ${ - hasTier2 ? checkMark(3) : exMark - } - ASCENDED Baller [+4%] - ${ - hasTier3 ? checkMark(4) : exMark - } - OMEGA Baller [+5%] - ${ - hasTier4 ? checkMark(5) : exMark - } - Discord Server Booster [+1%] - ${ - boosted ? checkMark(1) : exMark - } - And Finally... - Being YOURSELF! [+1%] - ${ + subtabElement.innerHTML = ` + Hello, ${user}!\n + Your personal Quark bonus is ${personalBonus}%, computed by the following: + Transcended Baller [+2%] - ${hasTier1 ? checkMark(2) : exMark} + Reincarnated Baller [+3%] - ${hasTier2 ? checkMark(3) : exMark} + ASCENDED Baller [+4%] - ${hasTier3 ? checkMark(4) : exMark} + OMEGA Baller [+5%] - ${hasTier4 ? checkMark(5) : exMark} + Discord Server Booster [+1%] - ${boosted ? checkMark(1) : exMark} + And Finally... + Being YOURSELF! [+1%] - ${ checkMark(1) } - The current maximum is 16%, by being a Discord server booster and an OMEGA Baller on Patreon! - - More will be incorporated both for general accounts and supporters of the game shortly. - Become a supporter of development via the link below, and get special bonuses, - while also improving the Global Bonus for all to enjoy! - - --> PATREON <-- - - ` + The current maximum is 16%, by being a Discord server booster and an OMEGA Baller on Patreon! + + More will be incorporated both for general accounts and supporters of the game shortly. + Become a supporter of development via the link below, and get special bonuses, + while also improving the Global Bonus for all to enjoy! + + --> PATREON <-- + + `.trim() + + const logoutElement = document.createElement('button') + logoutElement.addEventListener('click', logout, { once: true }) + logoutElement.style.cssText = 'border: 2px solid #5865F2; height: 25px; width: 150px;' + logoutElement.textContent = 'Log Out' + + subtabElement.appendChild(logoutElement) } else { // User is not logged in subtabElement.innerHTML = ` @@ -140,3 +138,11 @@ export async function handleLogin () { ` } } + +async function logout () { + if ('cookieStore' in window) { + await (window.cookieStore as { delete: (id: string) => Promise }).delete('id') + } else { + document.cookie = 'id=; Max-Age=0' + } +} From 857d06c2b785905d6d37e6dd8267f9ee8f9eb47c Mon Sep 17 00:00:00 2001 From: Khafra Date: Sun, 28 Jan 2024 22:38:52 -0500 Subject: [PATCH 2/3] logout --- src/Login.ts | 6 ++++++ translations/en.json | 3 +++ translations/source.json | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/Login.ts b/src/Login.ts index 1396eacd6..99069c2e8 100644 --- a/src/Login.ts +++ b/src/Login.ts @@ -1,6 +1,8 @@ +import i18next from 'i18next' import { DOMCacheGetOrSet } from './Cache/DOM' import { QuarkHandler } from './Quark' import { player } from './Synergism' +import { Alert } from './UpdateHTML' // Consts for Patreon Supporter Roles. const TRANSCENDED_BALLER = '756419583941804072' @@ -145,4 +147,8 @@ async function logout () { } else { document.cookie = 'id=; Max-Age=0' } + + await Alert(i18next.t('account.logout')) + + location.reload() } diff --git a/translations/en.json b/translations/en.json index 97b243a17..99f0b3818 100644 --- a/translations/en.json +++ b/translations/en.json @@ -3438,5 +3438,8 @@ "clicked": "See? Yet another reason to trust Unsmith. Ah well. For clicking me, you gain 5% more Offerings, Obtainium, and ALL Cubes until you refresh the page!", "clickedText": "You have clicked the <>! Until refresh, gain <>, <>, <>!" } + }, + "account": { + "logout": "The page will now reload. You are logged out! Goodbye!!" } } diff --git a/translations/source.json b/translations/source.json index e1476f80c..cc46aa033 100644 --- a/translations/source.json +++ b/translations/source.json @@ -3438,5 +3438,8 @@ "clicked": "See? Yet another reason to trust Unsmith. Ah well. For clicking me, you gain 5% more Offerings, Obtainium, and ALL Cubes until you refresh the page!", "clickedText": "You have clicked the <>! Until refresh, gain <>, <>, <>!" } + }, + "account": { + "logout": "The page will now reload. You are logged out! Goodbye!!" } } From 438de4d6b52b5c30ad468ebfe767e758ce0393be Mon Sep 17 00:00:00 2001 From: Khafra Date: Sun, 28 Jan 2024 22:56:39 -0500 Subject: [PATCH 3/3] username/nick fallbacks --- src/Login.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Login.ts b/src/Login.ts index 99069c2e8..ad4e0ed65 100644 --- a/src/Login.ts +++ b/src/Login.ts @@ -82,7 +82,7 @@ export async function handleLogin () { currentBonus.textContent += ` You also receive an extra ${personalBonus}% bonus for being a Patreon member and/or boosting the Discord server! Multiplicative with global bonus!` - const user = member?.user?.username ?? 'player' + const user = member?.nick ?? member?.user?.username ?? member?.user?.global_name const boosted = Boolean(member?.premium_since) const hasTier1 = member?.roles.includes(TRANSCENDED_BALLER) ?? false const hasTier2 = member?.roles.includes(REINCARNATED_BALLER) ?? false @@ -96,7 +96,7 @@ export async function handleLogin () { const exMark = '[✖] {+0%}' subtabElement.innerHTML = ` - Hello, ${user}!\n + ${user ? `Hello, ${user}` : 'Hello'}!\n Your personal Quark bonus is ${personalBonus}%, computed by the following: Transcended Baller [+2%] - ${hasTier1 ? checkMark(2) : exMark} Reincarnated Baller [+3%] - ${hasTier2 ? checkMark(3) : exMark}