Skip to content

Commit

Permalink
feat(SoundCloud): add use presence name setting (PreMiD#8743)
Browse files Browse the repository at this point in the history
Signed-off-by: github plz bring back DarkVIllager <[email protected]>
  • Loading branch information
darkvillager2 authored Sep 22, 2024
1 parent 4ca6a7a commit 8e88a49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 7 additions & 1 deletion websites/S/SoundCloud/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"vi_VN": "SoundCloud là nền tảng phát nhạc và podcast trực tuyến nơi bạn có thể nghe hàng triệu bài hát từ khắp thế giới, hoặc tự đăng tải tác phẩm của riêng mình."
},
"url": "soundcloud.com",
"version": "2.4.16",
"version": "2.5.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/S/SoundCloud/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/S/SoundCloud/assets/thumbnail.jpg",
"color": "#FF7E30",
Expand Down Expand Up @@ -76,6 +76,12 @@
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
},
{
"id": "usePresenceName",
"title": "Show Title as Presence",
"icon": "fad fa-user-edit",
"value": false
}
]
}
17 changes: 13 additions & 4 deletions websites/S/SoundCloud/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ presence.on("UpdateData", async () => {
showTimestamps,
showCover,
showButtons,
usePresenceName,
newLang,
] = await Promise.all([
presence.getSetting<boolean>("browse"),
Expand All @@ -127,6 +128,7 @@ presence.on("UpdateData", async () => {
presence.getSetting<boolean>("timestamp"),
presence.getSetting<boolean>("cover"),
presence.getSetting<boolean>("buttons"),
presence.getSetting<boolean>("usePresenceName"),
presence.getSetting<string>("lang").catch(() => "en"),
]),
playing = Boolean(document.querySelector(".playControls__play.playing"));
Expand All @@ -152,10 +154,17 @@ presence.on("UpdateData", async () => {
}

if ((playing || (!playing && !showBrowsing)) && showSong) {
presenceData.details = getElement(
".playbackSoundBadge__titleLink > span:nth-child(2)"
);
presenceData.state = getElement(".playbackSoundBadge__lightLink");
if (!usePresenceName) {
presenceData.details = getElement(
".playbackSoundBadge__titleLink > span:nth-child(2)"
);
presenceData.state = getElement(".playbackSoundBadge__lightLink");
} else {
presenceData.name = getElement(
".playbackSoundBadge__titleLink > span:nth-child(2)"
);
presenceData.details = getElement(".playbackSoundBadge__lightLink");
}

const timePassed = document.querySelector(
"div.playbackTimeline__timePassed > span:nth-child(2)"
Expand Down

0 comments on commit 8e88a49

Please sign in to comment.