Skip to content

Commit

Permalink
fix(Cytoid): update all selectors (PreMiD#7924)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerkig authored Jan 8, 2024
1 parent 39bad58 commit e3b6a1f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 45 deletions.
2 changes: 1 addition & 1 deletion websites/C/Cytoid/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"en": "Cytoid is a music game where you can create, share and play your own levels! Powered by community, with many dedicated creators, Cytoid provides a huge variety of musical genres to enjoy and a diverse range of gameplay design."
},
"url": "cytoid.io",
"version": "1.0.6",
"version": "2.0.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/thumbnail.png",
"color": "#476ADC",
Expand Down
77 changes: 33 additions & 44 deletions websites/C/Cytoid/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,84 +20,72 @@ presence.on("UpdateData", async () => {
if (document.location.pathname === "/levels") {
presenceData.details = "Browsing Levels";
presenceData.state = `${
document.querySelector("div.dropdown-trigger > button").textContent
document.querySelector("div.dropdown > div.btn")?.textContent
} ${
document.querySelector<SVGElement>("div.field > button > span > svg")
.dataset.icon === "sort-amount-up"
new URL(document.location.href).searchParams.get("order") === "asc"
? "↑"
: "↓"
}`;
const previewedCard = [...document.querySelectorAll("audio")].find(
element => !element.paused
)?.parentElement.parentElement.parentElement;
const previewedCard = document.querySelector(
".btn-ghost > div.radial-progress"
)?.parentElement.parentElement.parentElement.parentElement.parentElement;
if (previewedCard) {
presenceData.details =
previewedCard.querySelector(".content-title").textContent;
previewedCard.querySelector(".card-title").textContent;
presenceData.state =
previewedCard.querySelector(".content-subtitle").textContent;
previewedCard.querySelector(
".card-title"
).nextElementSibling.textContent;
presenceData.largeImageKey = previewedCard
.querySelector<HTMLDivElement>(".content-card-bg")
.querySelector<HTMLDivElement>(".base-card-bg")
.style.backgroundImage.slice(5, -2);
presenceData.endTimestamp = presence.getTimestampsfromMedia(
previewedCard.querySelector("audio")
)[1];
presenceData.smallImageKey = Assets.Play;
presenceData.smallImageText = "Playing Preview";
presenceData.buttons = [
{
label: "View Level",
url: previewedCard.querySelector<HTMLAnchorElement>(
".content-card-overlay"
).href,
},
{
label: "View Uploader",
url: previewedCard.querySelector<HTMLAnchorElement>(".link").href,
url: previewedCard.parentElement as HTMLAnchorElement,
},
];
}
} else {
presenceData.details = document.querySelector("h1").textContent;
presenceData.state = document.querySelector("h5").textContent;
presenceData.largeImageKey = document.querySelector<HTMLImageElement>(
"img.background-image"
).src;
presenceData.details =
document.querySelector("#contentTitle > h1").textContent;
presenceData.state =
document.querySelector("#contentTitle > p").textContent;
presenceData.largeImageKey = document.querySelector<HTMLMetaElement>(
"head > meta[property='og:image']"
).content;
presenceData.buttons = [
{
label: "View Level",
url: document.location.href,
},
{
label: "View Uploader",
url: document.querySelector<HTMLAnchorElement>(".player-avatar").href,
url: document.querySelector<HTMLAnchorElement>(".card-body > a").href,
},
];
if (!document.querySelector("audio").paused) {
presenceData.smallImageKey = Assets.Play;
presenceData.smallImageText = "Playing Preview";
presenceData.endTimestamp = presence.getTimestampsfromMedia(
document.querySelector("audio")
)[1];
}
}
}
if (document.location.pathname.startsWith("/collections")) {
if (document.location.pathname === "/collections")
presenceData.details = "Browsing Collections";
else {
presenceData.details = "Viewing Collection";
presenceData.state = document.querySelector("h1").textContent;
presenceData.largeImageKey = document.querySelector<HTMLImageElement>(
"img.background-image"
).src;
presenceData.state =
document.querySelector("#contentTitle > h1").textContent;
presenceData.largeImageKey = document.querySelector<HTMLMetaElement>(
"head > meta[property='og:image']"
).content;
presenceData.buttons = [
{
label: "View Level",
label: "View Collection",
url: document.location.href,
},
{
label: "View Uploader",
url: document.querySelector<HTMLAnchorElement>(".player-avatar").href,
url: document.querySelector<HTMLAnchorElement>(".card-body > a").href,
},
];
}
Expand All @@ -107,7 +95,8 @@ presence.on("UpdateData", async () => {
presenceData.details = "Browsing Posts";
else {
presenceData.details = "Viewing Post";
presenceData.state = document.querySelector("h1").textContent;
presenceData.state =
document.querySelector("#contentTitle > h1").textContent;
presenceData.buttons = [
{
label: "View Post",
Expand All @@ -118,9 +107,9 @@ presence.on("UpdateData", async () => {
}
if (document.location.pathname.startsWith("/profile")) {
presenceData.details = "Viewing Profile";
presenceData.state = document.querySelector(".username").textContent;
presenceData.state = document.querySelector("p.card-title").textContent;
presenceData.largeImageKey =
document.querySelector<HTMLImageElement>(".cytoid-avatar").src;
document.querySelector<HTMLImageElement>("#contentTitle img").src;
presenceData.buttons = [
{
label: "View Profile",
Expand All @@ -131,20 +120,20 @@ presence.on("UpdateData", async () => {
if (document.location.pathname.startsWith("/studio")) {
presenceData.details = "Viewing Studio";
presenceData.state = document.querySelector(
".is-exact-active > span"
"#StudioMenu .active"
).textContent;
}
if (document.location.pathname.startsWith("/settings")) {
presenceData.details = "Viewing Settings";
presenceData.state = document.querySelector(
".is-exact-active > span"
"#StudioMenu .active"
).textContent;
}
if (document.location.pathname === "/library")
presenceData.details = "Viewing Library";
if (document.location.pathname.startsWith("/pages/")) {
presenceData.details = `Viewing ${
document.querySelector("div.title").textContent
document.querySelector("h1").textContent
}`;
}
if (document.location.pathname === "/credits")
Expand Down

0 comments on commit e3b6a1f

Please sign in to comment.