From f361409271faebd3b5551f0a767ebce10de63bd5 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:05:41 +0700 Subject: [PATCH 01/12] feat(Weverse): add presence (#8724) --- package-lock.json | 2 +- websites/W/Weverse/metadata.json | 24 ++++ websites/W/Weverse/presence.ts | 189 +++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 websites/W/Weverse/metadata.json create mode 100644 websites/W/Weverse/presence.ts diff --git a/package-lock.json b/package-lock.json index d65205dd2ea0..9d9badbe25fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ }, "cli": { "name": "@pmd/cli", - "version": "1.3.2", + "version": "1.3.4", "license": "MPL-2.0", "dependencies": { "@apollo/client": "^3.6.9", diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json new file mode 100644 index 000000000000..f3d74a3ea972 --- /dev/null +++ b/websites/W/Weverse/metadata.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.10", + "author": { + "id": "712745906876842025", + "name": "hanifhan1f" + }, + "service": "Weverse", + "description": { + "en": "Displays the current live stream activity for a Weverse live page." + }, + "url": "weverse.io", + "version": "1.0.0", + "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", + "thumbnail": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211170/Presences/thumbnail.png", + "color": "#08ccc9", + "category": "music", + "tags": [ + "weverse", + "kpop", + "live", + "streaming", + "music" + ] +} \ No newline at end of file diff --git a/websites/W/Weverse/presence.ts b/websites/W/Weverse/presence.ts new file mode 100644 index 000000000000..8eaf45580fad --- /dev/null +++ b/websites/W/Weverse/presence.ts @@ -0,0 +1,189 @@ +class Weverse extends Presence { + constructor(options: PresenceOptions) { + super(options); + } + + getArtistName(): string { + return ( + document + .querySelector(".LiveArtistProfileView_name_item__8W66y") + ?.textContent?.trim() ?? "Unknown Artist" + ); + } + + getStreamTitle(): string { + const titleElement = document.querySelector("h2.TitleView_title__SSnHb"); + if (titleElement) { + const titleTextNodes = Array.from(titleElement.childNodes).filter( + node => + !( + node instanceof HTMLElement && + node.matches(".LiveBadgeView_badge__o2vFt") + ) + ); + + return ( + titleTextNodes + .map(node => node.textContent) + .join("") + .trim() || "Unknown Title" + ); + } + return "Unknown Title"; + } + + getThumbnailUrl(): string | undefined { + return document.querySelector( + ".ProfileThumbnailView_thumbnail_wrap__ZgeTf img" + )?.src; + } + + getCommunityName(): string { + return ( + document + .querySelector(".HeaderCommunityDropdownWrapperView_name__FZXsx") + ?.textContent?.trim() ?? "Unknown Community" + ); + } + + getCommunityImageUrl(): string | undefined { + return document.querySelector( + ".CommunityAsideWelcomeView_thumbnail__5MVun" + )?.src; + } + + getArtistPageName(): string { + return ( + document + .querySelector(".HeaderCommunityDropdownWrapperView_name__FZXsx") + ?.textContent?.trim() ?? "Unknown Artist" + ); + } + + getMomentThumbnailUrl(): string | undefined { + return document.querySelector( + ".ProfileThumbnailView_thumbnail_wrap__ZgeTf img" + )?.src; + } + + getMomentNickname(): string { + return ( + document + .querySelector(".PostHeaderView_nickname__6Cb7X") + ?.textContent?.trim() ?? "Unknown User" + ); + } +} + +const presence = new Weverse({ + clientId: "1284048129414402109", +}); + +presence.on("UpdateData", async () => { + const presenceData: PresenceData = { + largeImageKey: + "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", + }; + + if (document.location.pathname.includes("/live/")) { + const thumbnailUrl = presence.getThumbnailUrl(); + presenceData.details = presence.getStreamTitle(); + presenceData.state = presence.getArtistName(); + + const video = document.querySelector("video"); + if (document.querySelector(".LiveBadgeView_-replay__nNx34") !== null) { + presenceData.smallImageKey = Assets.Play; + presenceData.smallImageText = "Replay"; + presenceData.buttons = [ + { + label: `Watch ${presence.getArtistName()} Replay`, + url: document.location.href, + }, + ]; + } else if (video) { + if (video.paused) { + presenceData.smallImageKey = Assets.Play; + presenceData.smallImageText = "Paused"; + } else { + presenceData.smallImageKey = Assets.Live; + presenceData.smallImageText = "Live"; + } + presenceData.buttons = [ + { + label: `Visit ${presence.getArtistName()} Live`, + url: document.location.href, + }, + ]; + } else { + presenceData.smallImageKey = Assets.Play; + presenceData.smallImageText = "Playing"; + presenceData.buttons = [ + { + label: `Watch ${presence.getArtistName()} Replay`, + url: document.location.href, + }, + ]; + } + + if (thumbnailUrl) presenceData.largeImageKey = thumbnailUrl; + } else if (document.location.pathname === "/") { + presenceData.details = "Browsing Weverse"; + presenceData.state = "On Homepage"; + } else if (document.location.pathname.includes("/feed")) { + presenceData.details = "Viewing Community Feed"; + presenceData.state = presence.getCommunityName(); + + const communityImageUrl = presence.getCommunityImageUrl(); + if (communityImageUrl) presenceData.largeImageKey = communityImageUrl; + + presenceData.buttons = [ + { + label: `Visit ${presence.getCommunityName()} Feed`, + url: document.location.href, + }, + ]; + } else if (document.location.pathname.includes("/artist")) { + presenceData.details = "Viewing Artist"; + presenceData.state = presence.getArtistPageName(); + + presenceData.buttons = [ + { + label: `Visit ${presence.getArtistPageName()} Artist`, + url: document.location.href, + }, + ]; + } else if (document.location.pathname.includes("/moment")) { + presenceData.details = "Viewing Moment"; + presenceData.state = presence.getMomentNickname(); + + const momentThumbnailUrl = presence.getMomentThumbnailUrl(); + if (momentThumbnailUrl) presenceData.largeImageKey = momentThumbnailUrl; + + presenceData.buttons = [ + { + label: `Visit ${presence.getMomentNickname()} Moment`, + url: document.location.href, + }, + ]; + } else if (document.location.pathname.includes("/media")) { + presenceData.details = "Viewing Media"; + presenceData.state = presence.getCommunityName(); + + presenceData.buttons = [ + { + label: `Visit ${presence.getCommunityName()} Media`, + url: document.location.href, + }, + ]; + } else { + presenceData.details = "Browsing Weverse"; + presenceData.buttons = [ + { + label: "Go to Weverse", + url: "https://weverse.io", + }, + ]; + } + + presence.setActivity(presenceData); +}); From 24040696a5c6f7270489c8d6ed4d3b8441471696 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:32:48 +0700 Subject: [PATCH 02/12] feat(Weverse): add presence --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 9d9badbe25fe..d65205dd2ea0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ }, "cli": { "name": "@pmd/cli", - "version": "1.3.4", + "version": "1.3.2", "license": "MPL-2.0", "dependencies": { "@apollo/client": "^3.6.9", From e7c7e7dd8a4932e68b42317f0c25c99e028e83e6 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:37:41 +0700 Subject: [PATCH 03/12] feat(Weverse): add presence --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index f3d74a3ea972..792a6527d815 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -9,7 +9,7 @@ "en": "Displays the current live stream activity for a Weverse live page." }, "url": "weverse.io", - "version": "1.0.0", + "version": "1.0.1", "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", "thumbnail": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211170/Presences/thumbnail.png", "color": "#08ccc9", From 3aa2af2a68105922422ff0b51cb2b47da71abdf4 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:40:02 +0700 Subject: [PATCH 04/12] chore: update version --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index 792a6527d815..f8e0d0f97b87 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -9,7 +9,7 @@ "en": "Displays the current live stream activity for a Weverse live page." }, "url": "weverse.io", - "version": "1.0.1", + "version": "1.0.2", "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", "thumbnail": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211170/Presences/thumbnail.png", "color": "#08ccc9", From df660c7841598b60a3ab513d056b4abb12701e23 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:48:15 +0700 Subject: [PATCH 05/12] fix: update version --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index f8e0d0f97b87..78976a0e059a 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -9,7 +9,7 @@ "en": "Displays the current live stream activity for a Weverse live page." }, "url": "weverse.io", - "version": "1.0.2", + "version": "1.0.4", "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", "thumbnail": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211170/Presences/thumbnail.png", "color": "#08ccc9", From 176dd537b4786b64a1112369f5bb6d051665b8c5 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:50:20 +0700 Subject: [PATCH 06/12] fix: downgrade version --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index 78976a0e059a..f3d74a3ea972 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -9,7 +9,7 @@ "en": "Displays the current live stream activity for a Weverse live page." }, "url": "weverse.io", - "version": "1.0.4", + "version": "1.0.0", "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", "thumbnail": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211170/Presences/thumbnail.png", "color": "#08ccc9", From 607c9a99c90482d86a312345bf60667acaf760d8 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:57:19 +0700 Subject: [PATCH 07/12] fix: fix error --- websites/W/Weverse/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index f3d74a3ea972..228254b917d6 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -1,5 +1,6 @@ { "$schema": "https://schemas.premid.app/metadata/1.10", + "apiVersion ": "1", "author": { "id": "712745906876842025", "name": "hanifhan1f" From b7047c6d08b79bc5345847335cf66f0a0555d3d5 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:58:29 +0700 Subject: [PATCH 08/12] fix: fix error --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index 228254b917d6..c189e622e9b7 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -1,6 +1,6 @@ { "$schema": "https://schemas.premid.app/metadata/1.10", - "apiVersion ": "1", + "apiVersion": 1, "author": { "id": "712745906876842025", "name": "hanifhan1f" From afe47e1131d3ca6f89460c806a8e673dc2e1986a Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Tue, 1 Oct 2024 21:59:59 +0700 Subject: [PATCH 09/12] fix: fix error --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index c189e622e9b7..e479f9614289 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -1,5 +1,5 @@ { - "$schema": "https://schemas.premid.app/metadata/1.10", + "$schema": "https://schemas.premid.app/metadata/1.11", "apiVersion": 1, "author": { "id": "712745906876842025", From 45f3efa07905ed2535c31309babce507f3fc19ea Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Wed, 2 Oct 2024 14:16:13 +0700 Subject: [PATCH 10/12] fix: change logo and remove button on lines 180-185 --- websites/W/Weverse/metadata.json | 2 +- websites/W/Weverse/presence.ts | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index e479f9614289..06c89370f59c 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -11,7 +11,7 @@ }, "url": "weverse.io", "version": "1.0.0", - "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", + "logo": "https://res.cloudinary.com/debvitdiw/image/upload/v1727852958/Presences/WeverseLogo.png", "thumbnail": "https://res.cloudinary.com/debvitdiw/image/upload/v1726211170/Presences/thumbnail.png", "color": "#08ccc9", "category": "music", diff --git a/websites/W/Weverse/presence.ts b/websites/W/Weverse/presence.ts index 8eaf45580fad..faa790f0dee5 100644 --- a/websites/W/Weverse/presence.ts +++ b/websites/W/Weverse/presence.ts @@ -82,7 +82,7 @@ const presence = new Weverse({ presence.on("UpdateData", async () => { const presenceData: PresenceData = { largeImageKey: - "https://res.cloudinary.com/debvitdiw/image/upload/v1726211085/Presences/weverse.jpg", + "https://res.cloudinary.com/debvitdiw/image/upload/v1727852958/Presences/WeverseLogo.png", }; if (document.location.pathname.includes("/live/")) { @@ -175,14 +175,6 @@ presence.on("UpdateData", async () => { url: document.location.href, }, ]; - } else { - presenceData.details = "Browsing Weverse"; - presenceData.buttons = [ - { - label: "Go to Weverse", - url: "https://weverse.io", - }, - ]; } presence.setActivity(presenceData); From d992a1fa817a9e5c4208ce1e01f9166147c53ab0 Mon Sep 17 00:00:00 2001 From: Synxx12 Date: Sat, 5 Oct 2024 07:33:10 +0700 Subject: [PATCH 11/12] chore(weverse): improve selectors --- websites/W/Weverse/presence.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websites/W/Weverse/presence.ts b/websites/W/Weverse/presence.ts index faa790f0dee5..c349d03a4bdf 100644 --- a/websites/W/Weverse/presence.ts +++ b/websites/W/Weverse/presence.ts @@ -6,19 +6,19 @@ class Weverse extends Presence { getArtistName(): string { return ( document - .querySelector(".LiveArtistProfileView_name_item__8W66y") + .querySelector("[class*=LiveArtistProfileView_name_item]") ?.textContent?.trim() ?? "Unknown Artist" ); } getStreamTitle(): string { - const titleElement = document.querySelector("h2.TitleView_title__SSnHb"); + const titleElement = document.querySelector("h2[class*=TitleView_title]"); if (titleElement) { const titleTextNodes = Array.from(titleElement.childNodes).filter( node => !( node instanceof HTMLElement && - node.matches(".LiveBadgeView_badge__o2vFt") + node.matches("[class*=LiveBadgeView_badge]") ) ); @@ -34,42 +34,42 @@ class Weverse extends Presence { getThumbnailUrl(): string | undefined { return document.querySelector( - ".ProfileThumbnailView_thumbnail_wrap__ZgeTf img" + "[class*=ProfileThumbnailView_thumbnail_wrap] img" )?.src; } getCommunityName(): string { return ( document - .querySelector(".HeaderCommunityDropdownWrapperView_name__FZXsx") + .querySelector("[class*=HeaderCommunityDropdownWrapperView_name]") ?.textContent?.trim() ?? "Unknown Community" ); } getCommunityImageUrl(): string | undefined { return document.querySelector( - ".CommunityAsideWelcomeView_thumbnail__5MVun" + "[class*=CommunityAsideWelcomeView_thumbnail] img" )?.src; } getArtistPageName(): string { return ( document - .querySelector(".HeaderCommunityDropdownWrapperView_name__FZXsx") + .querySelector("[class*=HeaderCommunityDropdownWrapperView_name]") ?.textContent?.trim() ?? "Unknown Artist" ); } getMomentThumbnailUrl(): string | undefined { return document.querySelector( - ".ProfileThumbnailView_thumbnail_wrap__ZgeTf img" + "a[class*=PostHeaderView_thumbnail_wrap] img" )?.src; } getMomentNickname(): string { return ( document - .querySelector(".PostHeaderView_nickname__6Cb7X") + .querySelector("[class*=PostHeaderView_nickname]") ?.textContent?.trim() ?? "Unknown User" ); } @@ -91,7 +91,7 @@ presence.on("UpdateData", async () => { presenceData.state = presence.getArtistName(); const video = document.querySelector("video"); - if (document.querySelector(".LiveBadgeView_-replay__nNx34") !== null) { + if (document.querySelector("[class*=LiveBadgeView_-replay]") !== null) { presenceData.smallImageKey = Assets.Play; presenceData.smallImageText = "Replay"; presenceData.buttons = [ From 53b0e4450748daac8fc8d34430978c5b91c691bf Mon Sep 17 00:00:00 2001 From: Hanif <130474202+Synxx12@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:41:07 +0700 Subject: [PATCH 12/12] Update websites/W/Weverse/metadata.json Co-authored-by: Bas van Zanten Signed-off-by: Hanif <130474202+Synxx12@users.noreply.github.com> --- websites/W/Weverse/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/W/Weverse/metadata.json b/websites/W/Weverse/metadata.json index 06c89370f59c..1abe838df5f9 100644 --- a/websites/W/Weverse/metadata.json +++ b/websites/W/Weverse/metadata.json @@ -7,7 +7,7 @@ }, "service": "Weverse", "description": { - "en": "Displays the current live stream activity for a Weverse live page." + "en": "Enjoy every moment with artists on global fandom life platform Weverse." }, "url": "weverse.io", "version": "1.0.0",