minor: KDR great divide user stats tooltip

This commit is contained in:
Index 2024-06-28 10:41:09 -05:00
parent 0f7aea03b2
commit 57e4130ede
2 changed files with 92 additions and 85 deletions

View file

@ -160,7 +160,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
Kill Death Ratio Kill Death Ratio
</b> </b>
<span class="float-end"> <span class="float-end">
${KDR} ${KDR} <i class="fa-solid fa-circle-info" data-bs-toggle="tooltip" data-bs-title="KDR is a user's kills divided by the amount of times they have died. If their KDR is above 1, they are making a positive contribution. If their KDR is less than 1, that means they die more than they kill."></i>
</span> </span>
</div> </div>
<div class="mb-1"> <div class="mb-1">
@ -204,6 +204,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
document.getElementById('p+greatdivide_stats').innerHTML = "<div class=\"mb-3\">This user hasn't participated in The Great Divide.</div>" document.getElementById('p+greatdivide_stats').innerHTML = "<div class=\"mb-3\">This user hasn't participated in The Great Divide.</div>"
} }
} }
return true
} }
}); });

View file

@ -1,4 +1,8 @@
chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { (async () => {
Utilities = await import(chrome.runtime.getURL('resources/utils.js'))
.default
chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
Settings = result.PolyPlus_Settings || {}; Settings = result.PolyPlus_Settings || {};
if (Settings.TheGreatDivide.Enabled !== true) { if (Settings.TheGreatDivide.Enabled !== true) {
@ -24,9 +28,9 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result) {
} }
} }
} }
}) })
async function UnbalancedServerMarkers() { async function UnbalancedServerMarkers() {
const Team = (await (await fetch('https://api.polytoria.com/v1/users/' + JSON.parse(window.localStorage.getItem('p+account_info')).ID + '/greatdivide')).json()).team const Team = (await (await fetch('https://api.polytoria.com/v1/users/' + JSON.parse(window.localStorage.getItem('p+account_info')).ID + '/greatdivide')).json()).team
if (Team !== undefined) { if (Team !== undefined) {
const Servers = Array.from(document.getElementById('servers-tabpane').children) const Servers = Array.from(document.getElementById('servers-tabpane').children)
@ -59,9 +63,9 @@ async function UnbalancedServerMarkers() {
} }
}) })
} }
} }
async function UserStatsTab() { async function UserStatsTab() {
const EventSection = document.createElement('div') const EventSection = document.createElement('div')
EventSection.innerHTML = ` EventSection.innerHTML = `
<div class="d-grid mt-2 mb-4"></div> <div class="d-grid mt-2 mb-4"></div>
@ -83,8 +87,10 @@ async function UserStatsTab() {
</small> </small>
<lottie-player id="avatar-loading" src="https://c0.ptacdn.com/static/images/lottie/poly-brick-loading.2b51aa85.json" background="transparent" speed="1" style="width: 20%;height: auto;margin: -16px auto 50px;margin-top: 0px;" loop="" autoplay=""></lottie-player> <lottie-player id="avatar-loading" src="https://c0.ptacdn.com/static/images/lottie/poly-brick-loading.2b51aa85.json" background="transparent" speed="1" style="width: 20%;height: auto;margin: -16px auto 50px;margin-top: 0px;" loop="" autoplay=""></lottie-player>
` `
chrome.runtime.sendMessage({ await chrome.runtime.sendMessage({
action: "greatdivide_stats", action: "greatdivide_stats",
userID: document.querySelector('.dropdown-item.text-danger[href^="/report"]').getAttribute('href').split('?')[0].split('/')[3] userID: document.querySelector('.dropdown-item.text-danger[href^="/report"]').getAttribute('href').split('?')[0].split('/')[3]
}); });
} Utilities.InjectResource("registerTooltips")
}
})();