Skip to content

Commit

Permalink
feat(Stake.us): add presence
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Kwan committed Apr 20, 2024
1 parent c623ae5 commit e4526f0
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
42 changes: 42 additions & 0 deletions websites/S/Stake.us/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://schemas.premid.app/metadata/1.10",
"author": {
"id": "479492889601114113",
"name": "koolkev246"
},
"service": "Stake.us",
"description": {
"en": "Stake.us offers an the best social casino games online, all available to play for fun & free. Enjoy free games, from slots to blackjack, roulette & more."
},
"url": "stake.us",
"version": "1.0.0",
"logo": "https://i.imgur.com/X9jCmBM.jpeg",
"thumbnail": "https://i.imgur.com/lobHZwr.jpeg",
"color": "#1a2c3a",
"category": "games",
"tags": [
"stake",
"casino",
"gambling"
],
"settings": [
{
"id": "showBal",
"title": "Display Balance",
"icon": "fad fa-coins",
"value": true
},
{
"id": "showTimestamp",
"title": "Display Timestamp",
"icon": "fad fa-clock",
"value": true
},
{
"id": "showCurrentGame",
"title": "Display Current Game",
"icon": "fad fa-slot-machine",
"value": true
}
]
}
74 changes: 74 additions & 0 deletions websites/S/Stake.us/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const presence = new Presence({
clientId: "1231098376741982349",
}),
browsingTimestamp = Math.floor(Date.now() / 1000);

presence.on("UpdateData", async () => {
const [showBal, showTimestamp, showCurrentGame] = await Promise.all([
presence.getSetting<boolean>("showBal"),
presence.getSetting<boolean>("showTimestamp"),
presence.getSetting<boolean>("showCurrentGame"),
]),
presenceData: PresenceData = {
largeImageKey: "https://i.imgur.com/9jDaQ1b.png",
},
{ pathname, search } = window.location;

if (showTimestamp) presenceData.startTimestamp = browsingTimestamp;

if (pathname.includes("casino") && !pathname.includes("games")) {
if (pathname.includes("group")) {
presenceData.state = `Browsing ${pathname
.split("/group/")
.pop()
.replaceAll("-", " ")
.replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase())}...`;
} else presenceData.state = "Browsing Casino...";
} else if (pathname.includes("games")) {
if (showCurrentGame) {
presenceData.state = `Playing ${document
.querySelector("div.title-wrap > h1")
.textContent.trim()}`;
}
} else presenceData.state = "Browsing...";

if (showBal) {
const balanceElement = document.querySelector(
"div.currency > span.content > span"
),
currencyElement = document.querySelector(
"div.currency > span.variant-subtle"
);
let balance = "Unknown",
currency = "Currency";
if (balanceElement)
balance = balanceElement.textContent.trim().replace("&nbsp;", " ");

if (currencyElement) {
if (currencyElement.getAttribute("title") === "sweeps")
currency = "Stake Cash";
else currency = "Gold Coins";
}

if (pathname.includes("games"))
presenceData.details = "Balance: (In Use In Game)";
else if (!pathname.includes("games") && balance.includes(","))
presenceData.details = `Balance: ${balance} (${currency})`;
else presenceData.details = `Balance: ${balance} ${currency}`;

if (search.includes("modal=wallet"))
presenceData.state = "Checking Wallet...";
else if (search.includes("modal=vault"))
presenceData.state = "Checking Vault...";
else if (search.includes("modal=vip"))
presenceData.state = "Checking VIP Progress...";
else if (search.includes("modal=user"))
presenceData.state = "Checking Statistics...";
else if (pathname.includes("/transactions/"))
presenceData.state = "Viewing Transactions...";
else if (pathname.includes("/settings/"))
presenceData.state = "Adjusting Settings...";
}

presence.setActivity(presenceData);
});

0 comments on commit e4526f0

Please sign in to comment.