Skip to content

Commit

Permalink
fix(wcostream): add option for non iframe video (#8884)
Browse files Browse the repository at this point in the history
fix(wcostream): add option for non iframe video
  • Loading branch information
darkvillager2 authored Nov 13, 2024
1 parent 39840dc commit 75fae7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion websites/W/Wcostream/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 27 additions & 2 deletions websites/W/Wcostream/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ presence.on("UpdateData", async () => {
presence.getSetting<boolean>("timestamps"),
presence.getSetting<boolean>("cover"),
presence.getSetting<boolean>("buttons"),
]);
]),
directVideo = document.querySelector<HTMLVideoElement>("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];
Expand All @@ -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...";
Expand All @@ -75,5 +99,6 @@ presence.on("UpdateData", async () => {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (presenceData.endTimestamp) presenceData.type = ActivityType.Watching;
presence.setActivity(presenceData);
});

0 comments on commit 75fae7a

Please sign in to comment.