Skip to content

Commit

Permalink
feat(atomicradio): fix presence and added space names (PreMiD#7727)
Browse files Browse the repository at this point in the history
* fix(atomicradio): query selector for track-title changed

* fix(atomicradio): wrong play icons were displayed

* feat(atomicradio): show space name instead of id

* feat(atomicradio): other pages removed always show browsing

* fix(atomicradio): bump verison
  • Loading branch information
VocalZero authored Nov 5, 2023
1 parent cca7c70 commit 6a5ce3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
2 changes: 1 addition & 1 deletion websites/A/atomicradio/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"en": "The future of radio is here. Experience 12 Spaces with non-stop music you'll love."
},
"url": "atomic.radio",
"version": "1.0.1",
"version": "1.1.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/atomicradio/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/atomicradio/assets/thumbnail.jpg",
"color": "#a9f923",
Expand Down
42 changes: 13 additions & 29 deletions websites/A/atomicradio/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,33 @@ presence.on("UpdateData", () => {
smallImageKey: Assets.Search,
startTimestamp: browsingTimestamp,
},
player = document.querySelector<HTMLDivElement>("div.player"),
{ pathname } = document.location;
player = document.querySelector<HTMLDivElement>("div.player");

if (player) {
const spaceId = player.querySelector("#spaceId").textContent;
presenceData.largeImageKey = player.querySelector("#artwork").textContent;
presenceData.smallImageKey =
player.querySelector<HTMLButtonElement>('[id*="-button"]').id ===
"play-button"
? Assets.Pause
: Assets.Play;
? Assets.Play
: Assets.Pause;
presenceData.details =
player.querySelector<HTMLAnchorElement>("a.track-title").textContent;
player.querySelector<HTMLAnchorElement>("div.track-title").textContent;
presenceData.state =
player.querySelector<HTMLDivElement>("div.track-artist").textContent;
presenceData.endTimestamp = new Date(
player.querySelector("#endingAt").textContent
).getTime();
presenceData.smallImageText = spaceId.toUpperCase();
presenceData.smallImageText =
player.querySelector("div.track-space").textContent;
presenceData.buttons = [
{ label: "Listen", url: `https://atomic.radio/${spaceId}` },
{
label: "Listen",
url: `https://atomic.radio/${
player.querySelector("#spaceId").textContent
}`,
},
];
} else {
presenceData.details = "Browsing...";
if (pathname.includes("/statistics"))
presenceData.details = "Viewing statistics";
else if (pathname.includes("/streams"))
presenceData.details = "Viewing stream urls";
else if (pathname.includes("/about"))
presenceData.details = "Viewing about us";
else if (pathname.includes("/apply"))
presenceData.details = "Viewing apply";
else if (pathname.includes("/contributors"))
presenceData.details = "Viewing contributors";
else if (pathname.includes("/partners"))
presenceData.details = "Viewing partners";
else if (pathname.includes("/legal/imprint"))
presenceData.details = "Viewing imprint";
else if (pathname.includes("/legal/privacy"))
presenceData.details = "Viewing privacy";
else if (pathname.includes("/account"))
presenceData.details = "Viewing account";
}
} else presenceData.details = "Browsing...";

if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
Expand Down

0 comments on commit 6a5ce3f

Please sign in to comment.