Skip to content

Commit

Permalink
Update presence.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hibanka committed Feb 21, 2021
1 parent 402aa24 commit 810a7ee
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions websites/R/R6Stats/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,28 @@ presence.on("UpdateData", async () => {
};

if (window.location.pathname.includes('/leaderboards')) {
presenceData.details = "Leaderboards";
} else if (window.location.pathname.includes('/compare')) {
presenceData.details = "Comparing Players...";
presenceData.details = "Viewing Leaderboard:";

const selects = document.querySelectorAll("select");
const labels = [];

if (selects[0].selectedIndex == 0) {
labels.push("General");
labels.push(selects[2].options[selects[2].selectedIndex].label); // Stat Type
labels.push(selects[1].options[selects[1].selectedIndex].label); // Platform
} else {
labels.push("Seasonal");
labels.push(selects[4].options[selects[4].selectedIndex].label); // Stat Type
labels.push(selects[2].options[selects[2].selectedIndex].label); // Platform
}

presenceData.state = labels.join(" | ");
presenceData.buttons = [
{
label: "View Leaderboard",
url: document.location.href
}
];
} else if (window.location.pathname.includes('/search')) {
presenceData.details = "Searching Player:";
presenceData.state = document.querySelector(
Expand All @@ -23,10 +42,24 @@ presence.on("UpdateData", async () => {
presenceData.state = document.querySelector(
"#__layout > div > div.layout-default__content > div.container__wrapper--content > div > main > div > div.player-header > div.player-header__about > div.player-header__about__meta > div.player-header__about__meta--player > div > span.player-info__player__username"
).textContent.trim();
presenceData.buttons = [
{
label: "View Stats",
url: document.URL
.replace("/operators", "")
.replace("/seasons", "")
.replace("/weapons", "")
}
];
} else if (window.location.pathname.includes('/compare')) {
presenceData.details = "Viewing Page:";
presenceData.state = "Compare Players";
} else if (window.location.pathname.includes('/account')) {
presenceData.details = "Personal Account";
presenceData.details = "Viewing Page:";
presenceData.state = "Personal Account";
} else if (window.location.pathname.includes('/privacy-policy')) {
presenceData.details = "Privacy Policy";
presenceData.details = "Viewing Page:";
presenceData.state = "Privacy Policy";
} else {
presenceData.details = "Browsing...";
}
Expand Down

0 comments on commit 810a7ee

Please sign in to comment.