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

Added xero.gg support. #2451

Merged
merged 12 commits into from
Nov 11, 2020
21 changes: 21 additions & 0 deletions websites/X/Xero.gg/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"author": {
"name": "Dekirai",
"id": "146743774909825024"
},
"service": "xero.gg",
"description": {
"en": "xero.gg is a website Player- and Clan database for a private server of the game S4 League."
},
"url": "xero.gg",
"version": "1.0.0",
"logo": "https://i.imgur.com/7GG8BKZ.png",
"thumbnail": "https://i.imgur.com/QnQwYmY.png",
"color": "#428DE3",
"tags": [
"s4league",
"games",
"database"
],
"category": "games"
}
144 changes: 144 additions & 0 deletions websites/X/Xero.gg/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
const presence = new Presence({
clientId: "775372570563182592"
}),
strings = presence.getStrings({
browsing: "presence.activity.browsing"
});

function getTimeStamp() {
return Math.floor(Date.now() / 1000);
}

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "xero"
};

presenceData.startTimestamp = getTimeStamp();
if (document.location.pathname.includes("/player/")) {
const player_nickname = document.querySelector(
"#player-profile-header-heading > div:nth-child(2) > div > div > div.medium.normal-color-name"
).textContent;
presenceData.details = `Player: ${player_nickname}`;
presenceData.state = "Viewing Statistics";
try {
const player_clan = document.querySelector("#s4db-player-view-clan > a")
.textContent;
presenceData.details += `(${player_clan})`;
} catch {
//Catch nothing
}
if (document.location.pathname.includes("/matches")) {
presenceData.state = "Viewing Match History";
} else if (document.location.pathname.includes("/characters")) {
presenceData.state = "Viewing Characters";
} else if (document.location.pathname.includes("/inventory")) {
presenceData.state = "Viewing Inventory";
}
} else if (document.location.pathname.includes("/news")) {
presenceData.details = "Viewing a page:";
presenceData.state = "News";
try {
const news_title = document
.querySelector(
"#uniteddb-content > div.container.news-container > div.news-heading.with-button"
)
.textContent.split(" — ")[0];
presenceData.details = "Reading news:";
presenceData.state = `${news_title}`;
} catch {
//Catch nothing
}
} else if (document.location.pathname.includes("/clan")) {
const clan_name = document.querySelector(
"#player-profile-header-heading > div.medium.normal-color-name"
).textContent,
clan_members = document.querySelector(
"#clan-data-container > div > div.col-sm-3 > div > div.xero-pane-body > ul > li"
).lastChild.textContent,
clan_leader = document.querySelector(
"#clan-data-container > div > div.col-sm-9 > div:nth-child(2) > div > div > a > div.media-body.ml-2 > div.bold"
).textContent;
presenceData.details = `Clan: ${clan_name}`;
presenceData.state = `Leader: ${clan_leader}, ${clan_members}`;
} else if (document.location.pathname.includes("/leaderboards")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Leaderboards";
} else if (document.location.pathname.includes("/support")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Support";
if (document.location.pathname.includes("/ticket/new")) {
presenceData.details = "Support";
presenceData.state = "Writing a ticket...";
} else if (document.location.pathname.includes("/ticket/")) {
presenceData.details = "Support";
presenceData.state = "Viewing a ticket";
}
} else if (document.location.pathname.includes("/careers")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Careers";
if (document.location.pathname.includes("/careers/position/")) {
const careers_position = document.querySelector(
"#uniteddb-content > div.container.news-container > div.news-heading.with-button"
).textContent;
presenceData.details = "Careers";
presenceData.state = `Viewing ${careers_position}`;
} else if (document.location.pathname.includes("/careers/application/")) {
presenceData.details = "Careers";
presenceData.state = "Viewing applications";
}
} else if (document.location.pathname.includes("/download")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Download";
} else if (document.location.pathname.includes("/notifications")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Notifications";
} else if (document.location.pathname.includes("/chat")) {
const chat_opponent = document.querySelector(
"#s4db-chat-content-header-name > a"
).textContent;
presenceData.details = "Chatting with";
presenceData.state = chat_opponent;
} else if (document.location.pathname.includes("/settings")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Settings";
if (document.location.pathname.includes("/overview")) {
presenceData.details = "Settings";
presenceData.state = "Overview";
} else if (document.location.pathname.includes("/security")) {
presenceData.details = "Settings";
presenceData.state = "Security";
} else if (document.location.pathname.includes("/clan")) {
presenceData.details = "Settings";
presenceData.state = "Clan";
} else if (document.location.pathname.includes("/transactions")) {
presenceData.details = "Settings";
presenceData.state = "Transaction History";
}
} else if (document.location.pathname.includes("/signin")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Sign In";
if (document.location.pathname.includes("/setup")) {
presenceData.details = "Sign Up";
presenceData.state = "Choosing a nickname...";
}
} else if (document.location.pathname.includes("/signup")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Sign Up";
} else if (document.location.pathname.includes("/recover")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Account recover";
} else if (document.location.pathname.endsWith("/terms")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Terms of Service";
} else {
presenceData.details = (await strings).browsing;
}

if (presenceData.details == null) {
presence.setTrayTitle();
presence.setActivity();
} else {
presence.setActivity(presenceData);
}
});
6 changes: 6 additions & 0 deletions websites/X/Xero.gg/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}