forked from PreMiD/Presences
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PreMiD#3057 from Hibanka/master
Added R6Stats presence
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.0", | ||
"author": { | ||
"name": "Hibanka", | ||
"id": "467658348158779393" | ||
}, | ||
"url": "r6stats.com", | ||
"description": { | ||
"en": "View and compare your Rainbow Six: Siege statistics with millions of other players around the world!", | ||
"ru": "Посматривайте и сравнивайте свою статистику в Rainbow Six: Siege с миллионами других игроков со всего мира!" | ||
}, | ||
"service": "R6Stats", | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/DCvK0Bz.png", | ||
"thumbnail": "https://i.imgur.com/nOrZDpv.png", | ||
"color": "#ffda0c", | ||
"tags": [ | ||
"rainbow6" | ||
], | ||
"category": "games" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const presence = new Presence({ | ||
clientId: "812646634663837706" | ||
}), | ||
browsingStamp = Math.floor(Date.now() / 1000); | ||
|
||
presence.on("UpdateData", async () => { | ||
const presenceData: PresenceData = { | ||
largeImageKey: "logo", | ||
startTimestamp: browsingStamp | ||
}; | ||
|
||
if (window.location.pathname.includes('/leaderboards')) { | ||
presenceData.details = "Viewing Leaderboard:"; | ||
|
||
const selects = document.querySelectorAll("select"), | ||
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( | ||
"#__layout > div > div.layout-default__content > div.container__wrapper--content > div > main > div > div.page-search__wrapper > div > div > div.page-search__results__header--left > span.page-search__results__header--light" | ||
).textContent.trim().slice(1, -1); | ||
} else if (window.location.pathname.includes('/stats')) { | ||
presenceData.details = "Viewing Player:"; | ||
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 = "Viewing Page:"; | ||
presenceData.state = "Personal Account"; | ||
} else if (window.location.pathname.includes('/privacy-policy')) { | ||
presenceData.details = "Viewing Page:"; | ||
presenceData.state = "Privacy Policy"; | ||
} else { | ||
presenceData.details = "Browsing..."; | ||
} | ||
|
||
presence.setActivity(presenceData); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/" | ||
} | ||
} |