Skip to content

Commit

Permalink
fix: simplify presence timestamp assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
iuriineves committed Dec 30, 2024
1 parent d268dbd commit cc87f46
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions websites/S/Sflix/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ presence.on("UpdateData", async () => {
presenceData.smallImageText = "Searching";
presenceData.state = privacy
? ""
:
document
.querySelector("h2[class*='cat-heading']")
.textContent.split('"')[1] ||
document.querySelector("h2[class*='cat-heading']").textContent

: document
.querySelector("h2[class*='cat-heading']")
.textContent.split('"')[1] ||
document.querySelector("h2[class*='cat-heading']").textContent;

break;
}
case "home_search":
Expand Down Expand Up @@ -73,21 +72,17 @@ presence.on("UpdateData", async () => {
presenceData.details = privacy ? "Watching" : `${showTitle}`;
presenceData.state = privacy
? ""
: {document.querySelector(".on-air div h3")?.textContent ?? ""
: document.querySelector(".on-air div h3")?.textContent ?? "";
presenceData.largeImageKey =
thumbnail && thumbnailURL && !privacy ? thumbnailURL : Assets.Logo;

if (!video.paused) {
const timestamps = presence.getTimestamps(
video.currentTime,
video.duration
);
presenceData.smallImageKey = Assets.Play;
presenceData.smallImageText = "Playing";
if (!privacy) {
presenceData.startTimestamp = timestamps[0];
presenceData.endTimestamp = timestamps[1];
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestamps(video.currentTime, video.duration);
}
presenceData.smallImageKey = Assets.Play;
presenceData.smallImageText = "Playing";
} else {
presenceData.smallImageKey = Assets.Pause;
presenceData.smallImageText = "Paused";
Expand Down

0 comments on commit cc87f46

Please sign in to comment.