Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Stake.us): add presence #8287

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions websites/S/Stake.us/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$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",
"matches": [
"*://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
}
]
}
78 changes: 78 additions & 0 deletions websites/S/Stake.us/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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") &&
document.querySelector("div.title-wrap > a").textContent.trim() !==
"Stake Originals"
)
presenceData.details = `Balance: (In Play) ${currency}`;
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);
});
Loading