diff --git a/websites/W/Wcostream/metadata.json b/websites/W/Wcostream/metadata.json index 64ed7d4f7e57..3cb495e08671 100644 --- a/websites/W/Wcostream/metadata.json +++ b/websites/W/Wcostream/metadata.json @@ -11,7 +11,7 @@ }, "url": "www.wcostream.com", "regExp": "(www[.])?wcostream[.].{2,5}", - "version": "1.1.11", + "version": "1.1.12", "logo": "https://cdn.rcd.gg/PreMiD/websites/W/Wcostream/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/W/Wcostream/assets/thumbnail.png", "color": "#FFCE39", diff --git a/websites/W/Wcostream/presence.ts b/websites/W/Wcostream/presence.ts index e6ef88135c45..1c7354a05f01 100644 --- a/websites/W/Wcostream/presence.ts +++ b/websites/W/Wcostream/presence.ts @@ -31,13 +31,16 @@ presence.on("UpdateData", async () => { presence.getSetting("timestamps"), presence.getSetting("cover"), presence.getSetting("buttons"), - ]); + ]), + directVideo = document.querySelector("video"); + if (video.timeLeft !== "") { if (!title) { title = document.querySelector('[itemprop="partOfSeries"]')?.textContent ?? document.querySelector(".video-title")?.textContent ?? - document.querySelector(".entry-title")?.textContent; + document.querySelector(".entry-title")?.textContent ?? + document.title.split("|")[0]; } presenceData.details = "Watching:"; presenceData.state = title?.split("Episode")?.[0]; @@ -58,6 +61,27 @@ presence.on("UpdateData", async () => { presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; presenceData.smallImageText = video.paused ? "Paused" : "Playing"; presenceData.buttons = [{ label: "Watch Episode", url: document.URL }]; + } else if (directVideo) { + presenceData.smallImageKey = directVideo.paused + ? Assets.Pause + : Assets.Play; + presenceData.smallImageText = directVideo.paused + ? "Paused" + : "Playing back"; + + presenceData.details = "Watching:"; + presenceData.state = + document.querySelector(".jw-title-primary.jw-reset")?.textContent ?? + document.querySelector('[itemprop="partOfSeries"]')?.textContent ?? + document.querySelector(".video-title")?.textContent ?? + document.querySelector(".entry-title")?.textContent; + + presenceData.buttons = [{ label: "Watch Episode", url: document.URL }]; + + if (!directVideo.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = + presence.getTimestampsfromMedia(directVideo); + } } else if (pathname === "/") presenceData.details = "Home page"; else if (pathname.startsWith("/search")) { presenceData.details = "Searching..."; @@ -75,5 +99,6 @@ presence.on("UpdateData", async () => { delete presenceData.startTimestamp; delete presenceData.endTimestamp; } + if (presenceData.endTimestamp) presenceData.type = ActivityType.Watching; presence.setActivity(presenceData); });