Skip to content

Commit

Permalink
feat(user): add presence
Browse files Browse the repository at this point in the history
  • Loading branch information
zvbt committed Apr 23, 2024
1 parent 7615a0a commit 880e526
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
22 changes: 22 additions & 0 deletions websites/O/Ongaku/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://schemas.premid.app/metadata/1.10",
"author": {
"id": "709704536821858304",
"name": "cyadine"
},
"service": "Ongaku",
"description": {
"en": "Discover the best of Jpop and Kpop on Ongaku your go-to platform for streaming all your favorite Japanese and Korean pop music hits. Dive into the latest tracks, timeless classics, and carefully curated playlists that celebrate the vibrant world of Jpop and Kpop music."
},
"url": "ongaku.zvbt.space",
"version": "1.0.0",
"logo": "https://ongaku.zvbt.space/favicon.png",
"thumbnail": "https://ongaku.zvbt.space/preview.png",
"color": "#cba6f7",
"category": "music",
"tags": [
"music",
"kpop",
"jpop"
]
}
67 changes: 67 additions & 0 deletions websites/O/Ongaku/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const presence = new Presence({
clientId: "1232447632765485126",
});

const enum Assets {
Logo = "https://ongaku.zvbt.space/favicon.png",
}

presence.on("UpdateData", async () => {
const song: string = document.title.split(" | ")[0],
artist = song.split(" - ")[0],
songname = song.split(" - ").pop(),
presenceDataKpop: PresenceData = {
largeImageKey: Assets.Logo,
details: "Listening to",
state: `${artist} - ${songname}`,
buttons: [
{
label: "Listen Along",
url: "https://ongaku.zvbt.space",
},
],
},
presenceDataJpop: PresenceData = {
largeImageKey: Assets.Logo,
details: "Listening to",
state: `${artist} - ${songname}`,
buttons: [
{
label: "Listen Along",
url: "https://ongaku.zvbt.space/jpop",
},
],
},
presenceDataSong: PresenceData = {
largeImageKey: Assets.Logo,
details: "Browsing the songs lists",
buttons: [
{
label: "View the page",
url: "https://ongaku.zvbt.space/song",
},
],
},
presenceDataAbout: PresenceData = {
largeImageKey: Assets.Logo,
details: "Reading the about page",
buttons: [
{
label: "View the page",
url: "https://ongaku.zvbt.space/about",
},
],
};

if (document.location.pathname.match("/jpop"))
presence.setActivity(presenceDataJpop);

if (document.location.pathname.match("/song"))
presence.setActivity(presenceDataSong);

if (document.location.pathname.match("/about"))
presence.setActivity(presenceDataAbout);

if (document.location.pathname === "/")
presence.setActivity(presenceDataKpop);
});

0 comments on commit 880e526

Please sign in to comment.