From e3b6a1f963fe634e968a2cf25c7a49d15171d8c3 Mon Sep 17 00:00:00 2001 From: joerkig <44418429+joerkig@users.noreply.github.com> Date: Mon, 8 Jan 2024 21:30:35 +0100 Subject: [PATCH] fix(Cytoid): update all selectors (#7924) --- websites/C/Cytoid/metadata.json | 2 +- websites/C/Cytoid/presence.ts | 77 ++++++++++++++------------------- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/websites/C/Cytoid/metadata.json b/websites/C/Cytoid/metadata.json index 048faad4733c..e1df0e75ddc2 100644 --- a/websites/C/Cytoid/metadata.json +++ b/websites/C/Cytoid/metadata.json @@ -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", diff --git a/websites/C/Cytoid/presence.ts b/websites/C/Cytoid/presence.ts index 086245fc3c55..536c506474b7 100644 --- a/websites/C/Cytoid/presence.ts +++ b/websites/C/Cytoid/presence.ts @@ -20,48 +20,42 @@ 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("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(".content-card-bg") + .querySelector(".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( - ".content-card-overlay" - ).href, - }, - { - label: "View Uploader", - url: previewedCard.querySelector(".link").href, + url: previewedCard.parentElement as HTMLAnchorElement, }, ]; } } else { - presenceData.details = document.querySelector("h1").textContent; - presenceData.state = document.querySelector("h5").textContent; - presenceData.largeImageKey = document.querySelector( - "img.background-image" - ).src; + presenceData.details = + document.querySelector("#contentTitle > h1").textContent; + presenceData.state = + document.querySelector("#contentTitle > p").textContent; + presenceData.largeImageKey = document.querySelector( + "head > meta[property='og:image']" + ).content; presenceData.buttons = [ { label: "View Level", @@ -69,16 +63,9 @@ presence.on("UpdateData", async () => { }, { label: "View Uploader", - url: document.querySelector(".player-avatar").href, + url: document.querySelector(".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")) { @@ -86,18 +73,19 @@ presence.on("UpdateData", async () => { presenceData.details = "Browsing Collections"; else { presenceData.details = "Viewing Collection"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.largeImageKey = document.querySelector( - "img.background-image" - ).src; + presenceData.state = + document.querySelector("#contentTitle > h1").textContent; + presenceData.largeImageKey = document.querySelector( + "head > meta[property='og:image']" + ).content; presenceData.buttons = [ { - label: "View Level", + label: "View Collection", url: document.location.href, }, { label: "View Uploader", - url: document.querySelector(".player-avatar").href, + url: document.querySelector(".card-body > a").href, }, ]; } @@ -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", @@ -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(".cytoid-avatar").src; + document.querySelector("#contentTitle img").src; presenceData.buttons = [ { label: "View Profile", @@ -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")