From 81580ba71e8c5077352c76390bc27bee7c529ea1 Mon Sep 17 00:00:00 2001 From: yuri Date: Sat, 28 Dec 2024 21:22:28 +0000 Subject: [PATCH] refactor(Sflix): prettier refactor --- websites/S/Sflix/presence.ts | 62 +++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/websites/S/Sflix/presence.ts b/websites/S/Sflix/presence.ts index dc4efd743f4d..d9d408a8a606 100644 --- a/websites/S/Sflix/presence.ts +++ b/websites/S/Sflix/presence.ts @@ -13,30 +13,38 @@ let video = { paused: true, }; -presence.on("iFrameData", (data: { duration: number, currentTime: number, paused: boolean }) => { - video = data; -}); +presence.on( + "iFrameData", + (data: { duration: number; currentTime: number; paused: boolean }) => { + video = data; + } +); presence.on("UpdateData", async () => { const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - type: ActivityType.Watching, - startTimestamp: browsingTimestamp, - }, - - [ thumbnail, privacy ] = await Promise.all([ - presence.getSetting("thumbnail"), - presence.getSetting("privacy"), - ]), - - variables = await presence.getPageVariable("currPage"); + largeImageKey: Assets.Logo, + type: ActivityType.Watching, + startTimestamp: browsingTimestamp, + }, + [thumbnail, privacy] = await Promise.all([ + presence.getSetting("thumbnail"), + presence.getSetting("privacy"), + ]), + variables = await presence.getPageVariable("currPage"); switch (variables.currPage) { case "": { presenceData.details = "Searching"; presenceData.smallImageKey = Assets.Search; presenceData.smallImageText = "Searching"; - presenceData.state = privacy ? "" : `${document.querySelector("h2[class*='cat-heading']").textContent.split('"')[1] || document.querySelector("h2[class*='cat-heading']").textContent}`; + presenceData.state = privacy + ? "" + : `${ + document + .querySelector("h2[class*='cat-heading']") + .textContent.split('"')[1] || + document.querySelector("h2[class*='cat-heading']").textContent + }`; break; } case "home_search": @@ -49,23 +57,31 @@ presence.on("UpdateData", async () => { } case "detail": { presenceData.details = "Browsing"; - presenceData.state = privacy ? "" : document.querySelector(".heading-name")?.textContent; + presenceData.state = privacy + ? "" + : document.querySelector(".heading-name")?.textContent; presenceData.smallImageKey = Assets.Reading; presenceData.smallImageText = "Browsing"; break; } case "watch": { - const showTitle = document.querySelector(".heading-name").textContent, - thumbnailURL = document.querySelector(`img[title*="${showTitle}"]`)?.getAttribute("src"); - + thumbnailURL = document + .querySelector(`img[title*="${showTitle}"]`) + ?.getAttribute("src"); + presenceData.details = privacy ? "Watching" : `${showTitle}`; - presenceData.state = privacy ? "" : `${document.querySelector(".on-air div h3")?.textContent || ""}`; - presenceData.largeImageKey = (thumbnail && thumbnailURL && !privacy) ? thumbnailURL : Assets.Logo; - + presenceData.state = privacy + ? "" + : `${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); + const timestamps = presence.getTimestamps( + video.currentTime, + video.duration + ); presenceData.smallImageKey = Assets.Play; presenceData.smallImageText = "Playing"; if (!privacy) {