Skip to content

Commit 772735f

Browse files
committed
2 parents 2757a6b + 438de4d commit 772735f

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

src/Login.ts

+41-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import i18next from 'i18next'
12
import { DOMCacheGetOrSet } from './Cache/DOM'
23
import { QuarkHandler } from './Quark'
34
import { player } from './Synergism'
5+
import { Alert } from './UpdateHTML'
46

57
// Consts for Patreon Supporter Roles.
68
const TRANSCENDED_BALLER = '756419583941804072'
@@ -80,7 +82,7 @@ export async function handleLogin () {
8082
currentBonus.textContent +=
8183
` You also receive an extra ${personalBonus}% bonus for being a Patreon member and/or boosting the Discord server! Multiplicative with global bonus!`
8284

83-
const user = member?.user?.username ?? 'player'
85+
const user = member?.nick ?? member?.user?.username ?? member?.user?.global_name
8486
const boosted = Boolean(member?.premium_since)
8587
const hasTier1 = member?.roles.includes(TRANSCENDED_BALLER) ?? false
8688
const hasTier2 = member?.roles.includes(REINCARNATED_BALLER) ?? false
@@ -93,37 +95,35 @@ export async function handleLogin () {
9395

9496
const exMark = '<span style="color: crimson">[✖] {+0%}</span>'
9597

96-
subtabElement.innerHTML = `Hello, ${user}!\n
97-
Your personal Quark bonus is ${personalBonus}%, computed by the following:
98-
<span style="color: orchid">Transcended Baller</span> [+2%] - ${
99-
hasTier1 ? checkMark(2) : exMark
100-
}
101-
<span style="color: green">Reincarnated Baller</span> [+3%] - ${
102-
hasTier2 ? checkMark(3) : exMark
103-
}
104-
<span style="color: orange">ASCENDED Baller</span> [+4%] - ${
105-
hasTier3 ? checkMark(4) : exMark
106-
}
107-
<span style="color: lightgoldenrodyellow">OMEGA Baller</span> [+5%] - ${
108-
hasTier4 ? checkMark(5) : exMark
109-
}
110-
<span style="color: #f47fff">Discord Server Booster</span> [+1%] - ${
111-
boosted ? checkMark(1) : exMark
112-
}
113-
And Finally...
114-
<span style="color: lime"> Being <span style="color: lightgoldenrodyellow"> YOURSELF! </span></span> [+1%] - ${
98+
subtabElement.innerHTML = `
99+
${user ? `Hello, ${user}` : 'Hello'}!\n
100+
Your personal Quark bonus is ${personalBonus}%, computed by the following:
101+
<span style="color: orchid">Transcended Baller</span> [+2%] - ${hasTier1 ? checkMark(2) : exMark}
102+
<span style="color: green">Reincarnated Baller</span> [+3%] - ${hasTier2 ? checkMark(3) : exMark}
103+
<span style="color: orange">ASCENDED Baller</span> [+4%] - ${hasTier3 ? checkMark(4) : exMark}
104+
<span style="color: lightgoldenrodyellow">OMEGA Baller</span> [+5%] - ${hasTier4 ? checkMark(5) : exMark}
105+
<span style="color: #f47fff">Discord Server Booster</span> [+1%] - ${boosted ? checkMark(1) : exMark}
106+
And Finally...
107+
<span style="color: lime"> Being <span style="color: lightgoldenrodyellow"> YOURSELF! </span></span> [+1%] - ${
115108
checkMark(1)
116109
}
117110
118-
The current maximum is 16%, by being a Discord server booster and an OMEGA Baller on Patreon!
119-
120-
More will be incorporated both for general accounts and supporters of the game shortly.
121-
Become a supporter of development via the link below, and get special bonuses,
122-
while also improving the Global Bonus for all to enjoy!
123-
<a href="https://www.patreon.com/synergism" target="_blank" rel="noopener noreferrer nofollow">
124-
<span style="color: lightgoldenrodyellow">--> PATREON <--</span>
125-
</a>
126-
`
111+
The current maximum is 16%, by being a Discord server booster and an OMEGA Baller on Patreon!
112+
113+
More will be incorporated both for general accounts and supporters of the game shortly.
114+
Become a supporter of development via the link below, and get special bonuses,
115+
while also improving the Global Bonus for all to enjoy!
116+
<a href="https://www.patreon.com/synergism" target="_blank" rel="noopener noreferrer nofollow">
117+
<span style="color: lightgoldenrodyellow">--> PATREON <--</span>
118+
</a>
119+
`.trim()
120+
121+
const logoutElement = document.createElement('button')
122+
logoutElement.addEventListener('click', logout, { once: true })
123+
logoutElement.style.cssText = 'border: 2px solid #5865F2; height: 25px; width: 150px;'
124+
logoutElement.textContent = 'Log Out'
125+
126+
subtabElement.appendChild(logoutElement)
127127
} else {
128128
// User is not logged in
129129
subtabElement.innerHTML = `
@@ -140,3 +140,15 @@ export async function handleLogin () {
140140
`
141141
}
142142
}
143+
144+
async function logout () {
145+
if ('cookieStore' in window) {
146+
await (window.cookieStore as { delete: (id: string) => Promise<void> }).delete('id')
147+
} else {
148+
document.cookie = 'id=; Max-Age=0'
149+
}
150+
151+
await Alert(i18next.t('account.logout'))
152+
153+
location.reload()
154+
}

translations/en.json

+3
Original file line numberDiff line numberDiff line change
@@ -3453,5 +3453,8 @@
34533453
"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!",
34543454
"clickedText": "You have clicked the <<white|Unsmith>>! Until refresh, gain <<orange|+5% Offerings>>, <<pink|+5% Obtainium>>, <<white|+5% ALL Cubes>>!"
34553455
}
3456+
},
3457+
"account": {
3458+
"logout": "The page will now reload. You are logged out! Goodbye!!"
34563459
}
34573460
}

translations/source.json

+3
Original file line numberDiff line numberDiff line change
@@ -3438,5 +3438,8 @@
34383438
"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!",
34393439
"clickedText": "You have clicked the <<white|Unsmith>>! Until refresh, gain <<orange|+5% Offerings>>, <<pink|+5% Obtainium>>, <<white|+5% ALL Cubes>>!"
34403440
}
3441+
},
3442+
"account": {
3443+
"logout": "The page will now reload. You are logged out! Goodbye!!"
34413444
}
34423445
}

0 commit comments

Comments
 (0)