Add "Place Achievements Progress Bar" Feature

This commit is contained in:
Index 2024-03-27 12:31:51 -05:00
parent 066babda56
commit a8cf983e26
4 changed files with 35 additions and 7 deletions

View file

@ -4,7 +4,7 @@
> [!IMPORTANT] > [!IMPORTANT]
> This extension is currently in BETA. If you find any bugs, please report them in this repository's issues section as it'd be a great help towards development of the extension. > This extension is currently in BETA. If you find any bugs, please report them in this repository's issues section as it'd be a great help towards development of the extension.
> [!ROADMAP] > [!TIP]
> Want to learn what's in store for Poly+? Check out the roadmap [here](https://github.com/users/indexxing/projects/2)! > Want to learn what's in store for Poly+? Check out the roadmap [here](https://github.com/users/indexxing/projects/2)!
# Poly+ # Poly+

View file

@ -230,7 +230,7 @@ async function OutfitCost() {
const ResultText = document.createElement('small') const ResultText = document.createElement('small')
ResultText.classList = 'fw-normal text-success' ResultText.classList = 'fw-normal text-success'
ResultText.style.letterSpacing = '0px' ResultText.style.letterSpacing = '0px'
ResultText.innerHTML = `(<i class="pi pi-brick mx-1"></i> ${ (AvatarCost.Limiteds > 0 || AvatarCost.Exclusives > 0) ? '~' : '' } ${ AvatarCost.Total.toLocaleString() }${ (AvatarCost.Limiteds > 0) ? `, ${AvatarCost.Limiteds} limiteds` : '' }${ (AvatarCost.Exclusives > 0) ? `, ${AvatarCost.Exclusives} exclusives` : '' })` ResultText.innerHTML = `(<i class="pi pi-brick mx-1"></i> ${ (AvatarCost.Limiteds > 0 || AvatarCost.Exclusives > 0) ? '~' : '' }${ AvatarCost.Total.toLocaleString() }${ (AvatarCost.Limiteds > 0) ? `, ${AvatarCost.Limiteds} limited` : '' }${ (AvatarCost.Exclusives > 0) ? `, ${AvatarCost.Exclusives} exclusive` : '' })`
CalculateButton.remove() CalculateButton.remove()
AvatarHeading.appendChild(ResultText) AvatarHeading.appendChild(ResultText)

View file

@ -92,6 +92,8 @@ let CalculateRevenueButton;
} }
}) })
} }
AchievementProgressBar()
}); });
})() })()
@ -439,7 +441,6 @@ async function OwnedTags() {
} }
async function PlaceRevenue() { async function PlaceRevenue() {
console.log('place revenue ran')
const Visits = parseInt(document.querySelector('li:has(i.fad.fa-users.text-muted[style])').innerText) const Visits = parseInt(document.querySelector('li:has(i.fad.fa-users.text-muted[style])').innerText)
const BricksPerView = 5 const BricksPerView = 5
let Revenue = (round5(Visits) / 5) let Revenue = (round5(Visits) / 5)
@ -457,8 +458,6 @@ async function PlaceRevenue() {
break break
} }
console.log('CREATOR TAX: ' + CreatorTax)
fetch(`https://api.polytoria.com/v1/places/${PlaceID}/gamepasses`) fetch(`https://api.polytoria.com/v1/places/${PlaceID}/gamepasses`)
.then(response => { .then(response => {
if (!response.ok) { if (!response.ok) {
@ -485,4 +484,33 @@ async function PlaceRevenue() {
}) })
} }
function round5(number) { const remainder = number % 5; if (remainder < 2.5) { return number - remainder; } else { return number + (5 - remainder); } } function round5(number) { const remainder = number % 5; if (remainder < 2.5) { return number - remainder; } else { return number + (5 - remainder); } }
function AchievementProgressBar() {
const Achievements = document.getElementById('achievements-tabpane')
const AchievementCount = Achievements.children.length
let AchievementsEarned = 0
for (let achievement of Array.from(Achievements.children)) {
const Achieved = (achievement.getElementsByClassName('fad fa-calendar')[0] !== undefined)
if (Achieved === true) {
AchievementsEarned++
}
}
const PercentageEarned = ((AchievementsEarned*100)/AchievementCount).toFixed(0)
const ProgressBar = document.createElement('div')
ProgressBar.role = 'progressbar'
ProgressBar.classList = 'progress'
ProgressBar.style.background = '#000'
ProgressBar.ariaValueNow = PercentageEarned
ProgressBar.ariaValueMin = "0"
ProgressBar.ariaValueMax = "100"
ProgressBar.innerHTML = `<div class="progress-bar progress-bar-striped text-bg-warning" style="width: ${PercentageEarned}%">${PercentageEarned}%</div>`
Achievements.prepend(document.createElement('hr'))
Achievements.prepend(ProgressBar)
}

View file

@ -510,7 +510,7 @@
<br> <br>
<span class="desc">Quickly see how many bricks a user has gained from one of their places!</span> <span class="desc">Quickly see how many bricks a user has gained from one of their places!</span>
<br> <br>
<span style="font-size: 0.8rem; color: orange;">* Gamepass revenue is calculated assuming the price hasn't changed and all users that bought the gamepass, bought it at the same price.</span> <span style="font-size: 0.8rem; color: orange;">* Gamepass revenue is calculated assuming the price hasn't changed and all users that bought the gamepass, bought it at the same price that it is at the time of calculating.</span>
</p> </p>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">