Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseudonian committed Mar 1, 2024
2 parents 2757a6b + 438de4d commit 772735f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
70 changes: 41 additions & 29 deletions src/Login.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -80,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
Expand All @@ -93,37 +95,35 @@ export async function handleLogin () {

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

subtabElement.innerHTML = `Hello, ${user}!\n
Your personal Quark bonus is ${personalBonus}%, computed by the following:
<span style="color: orchid">Transcended Baller</span> [+2%] - ${
hasTier1 ? checkMark(2) : exMark
}
<span style="color: green">Reincarnated Baller</span> [+3%] - ${
hasTier2 ? checkMark(3) : exMark
}
<span style="color: orange">ASCENDED Baller</span> [+4%] - ${
hasTier3 ? checkMark(4) : exMark
}
<span style="color: lightgoldenrodyellow">OMEGA Baller</span> [+5%] - ${
hasTier4 ? checkMark(5) : exMark
}
<span style="color: #f47fff">Discord Server Booster</span> [+1%] - ${
boosted ? checkMark(1) : exMark
}
And Finally...
<span style="color: lime"> Being <span style="color: lightgoldenrodyellow"> YOURSELF! </span></span> [+1%] - ${
subtabElement.innerHTML = `
${user ? `Hello, ${user}` : 'Hello'}!\n
Your personal Quark bonus is ${personalBonus}%, computed by the following:
<span style="color: orchid">Transcended Baller</span> [+2%] - ${hasTier1 ? checkMark(2) : exMark}
<span style="color: green">Reincarnated Baller</span> [+3%] - ${hasTier2 ? checkMark(3) : exMark}
<span style="color: orange">ASCENDED Baller</span> [+4%] - ${hasTier3 ? checkMark(4) : exMark}
<span style="color: lightgoldenrodyellow">OMEGA Baller</span> [+5%] - ${hasTier4 ? checkMark(5) : exMark}
<span style="color: #f47fff">Discord Server Booster</span> [+1%] - ${boosted ? checkMark(1) : exMark}
And Finally...
<span style="color: lime"> Being <span style="color: lightgoldenrodyellow"> YOURSELF! </span></span> [+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!
<a href="https://www.patreon.com/synergism" target="_blank" rel="noopener noreferrer nofollow">
<span style="color: lightgoldenrodyellow">--> PATREON <--</span>
</a>
`
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!
<a href="https://www.patreon.com/synergism" target="_blank" rel="noopener noreferrer nofollow">
<span style="color: lightgoldenrodyellow">--> PATREON <--</span>
</a>
`.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 = `
Expand All @@ -140,3 +140,15 @@ export async function handleLogin () {
`
}
}

async function logout () {
if ('cookieStore' in window) {
await (window.cookieStore as { delete: (id: string) => Promise<void> }).delete('id')
} else {
document.cookie = 'id=; Max-Age=0'
}

await Alert(i18next.t('account.logout'))

location.reload()
}
3 changes: 3 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3453,5 +3453,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 <<white|Unsmith>>! Until refresh, gain <<orange|+5% Offerings>>, <<pink|+5% Obtainium>>, <<white|+5% ALL Cubes>>!"
}
},
"account": {
"logout": "The page will now reload. You are logged out! Goodbye!!"
}
}
3 changes: 3 additions & 0 deletions translations/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<white|Unsmith>>! Until refresh, gain <<orange|+5% Offerings>>, <<pink|+5% Obtainium>>, <<white|+5% ALL Cubes>>!"
}
},
"account": {
"logout": "The page will now reload. You are logged out! Goodbye!!"
}
}

0 comments on commit 772735f

Please sign in to comment.