From 811741ec40b855d8ded2996accc042ba2c922c1f Mon Sep 17 00:00:00 2001 From: Kitosight Date: Wed, 15 Jan 2025 21:36:33 +0300 Subject: [PATCH 1/3] chore(AnimeLib): cache current dub feat(AnimeLib): title as presence setting --- websites/A/AnimeLib/metadata.json | 20 +++++++++++++------- websites/A/AnimeLib/presence.ts | 27 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/websites/A/AnimeLib/metadata.json b/websites/A/AnimeLib/metadata.json index 56ec41c1381c..3dbef3ee869a 100644 --- a/websites/A/AnimeLib/metadata.json +++ b/websites/A/AnimeLib/metadata.json @@ -14,19 +14,25 @@ "ru": "Смотрите аниме онлайн на русском" }, "url": "anilib.me", - "version": "1.0.5", + "version": "1.0.6", "logo": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeLib/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeLib/assets/thumbnail.png", "color": "#A020F0", "category": "anime", "tags": [ "anime", - "video", - "community" + "community", + "lib" ], "iframe": true, "iFrameRegExp": "kodik[.]info", "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-shield-alt", + "value": false + }, { "id": "buttons", "title": "Show Buttons", @@ -34,10 +40,10 @@ "value": true }, { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", + "id": "titleAsPresence", + "title": "Show Anime Title As Presence", + "icon": "fad fa-user-edit", "value": false } ] -} \ No newline at end of file +} diff --git a/websites/A/AnimeLib/presence.ts b/websites/A/AnimeLib/presence.ts index 6fea0b8b06f3..ece5bd203d98 100644 --- a/websites/A/AnimeLib/presence.ts +++ b/websites/A/AnimeLib/presence.ts @@ -37,7 +37,7 @@ const isPrivacyMode = (setting: boolean, ageRestriction?: AgeRestriction) => cleanUrl = (location: Location) => location.href.replace(location.search, "").replace("/watch", ""); -let iFrameVideo: IFrameVideo; +let iFrameVideo: IFrameVideo, currentDub: string; presence.on("iFrameData", (data: IFrameVideo) => { iFrameVideo = data; @@ -51,9 +51,10 @@ presence.on("UpdateData", async () => { largeImageText: "AnimeLib", smallImageText: "AnimeLib", }, - [privacySetting, buttonsSetting] = await Promise.all([ + [privacySetting, buttonsSetting, titleSetting] = await Promise.all([ presence.getSetting("privacy"), presence.getSetting("buttons"), + presence.getSetting("titleAsPresence"), ]), path = document.location.pathname; @@ -115,12 +116,26 @@ presence.on("UpdateData", async () => { .querySelectorAll(".btn.is-outline")[7] ?.querySelector("span")?.textContent; - if (dub) { - presenceData.details = - animeData.rus_name !== "" ? animeData.rus_name : animeData.name; + if (dub || currentDub) { + /** + * This makes sure that the dub will always be defined. + * When user changes menu between dubs/subs, the menu items are different, + * so it's not possible to get the current active item if it's in a different menu. + */ + if (dub) currentDub = dub; + + // presenceData.details = + // animeData.rus_name !== "" ? animeData.rus_name : animeData.name; + titleSetting + ? (presenceData.name = + animeData.rus_name !== "" ? animeData.rus_name : animeData.name) + : (presenceData.details = + animeData.rus_name !== "" + ? animeData.rus_name + : animeData.name); presenceData.state = `${ episode ? (episode.includes("эпизод") ? episode : "Фильм") : "Фильм" - } | ${dub}`; + } | ${currentDub}`; presenceData.largeImageKey = animeData.cover.default; presenceData.largeImageText = animeData.rus_name !== "" ? animeData.rus_name : animeData.name; From 30bbfdc11ce45f2b2cd26beed8f927466b99338e Mon Sep 17 00:00:00 2001 From: Kitosight Date: Wed, 15 Jan 2025 21:42:17 +0300 Subject: [PATCH 2/3] chore(AnimeLib): code readability --- websites/A/AnimeLib/metadata.json | 2 +- websites/A/AnimeLib/presence.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/websites/A/AnimeLib/metadata.json b/websites/A/AnimeLib/metadata.json index 3dbef3ee869a..fa7e0610c5b3 100644 --- a/websites/A/AnimeLib/metadata.json +++ b/websites/A/AnimeLib/metadata.json @@ -14,7 +14,7 @@ "ru": "Смотрите аниме онлайн на русском" }, "url": "anilib.me", - "version": "1.0.6", + "version": "1.0.7", "logo": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeLib/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeLib/assets/thumbnail.png", "color": "#A020F0", diff --git a/websites/A/AnimeLib/presence.ts b/websites/A/AnimeLib/presence.ts index ece5bd203d98..7ec7ae972399 100644 --- a/websites/A/AnimeLib/presence.ts +++ b/websites/A/AnimeLib/presence.ts @@ -124,21 +124,19 @@ presence.on("UpdateData", async () => { */ if (dub) currentDub = dub; + const title = + animeData.rus_name !== "" ? animeData.rus_name : animeData.name; + // presenceData.details = // animeData.rus_name !== "" ? animeData.rus_name : animeData.name; titleSetting - ? (presenceData.name = - animeData.rus_name !== "" ? animeData.rus_name : animeData.name) - : (presenceData.details = - animeData.rus_name !== "" - ? animeData.rus_name - : animeData.name); + ? (presenceData.name = title) + : (presenceData.details = title); presenceData.state = `${ episode ? (episode.includes("эпизод") ? episode : "Фильм") : "Фильм" } | ${currentDub}`; presenceData.largeImageKey = animeData.cover.default; - presenceData.largeImageText = - animeData.rus_name !== "" ? animeData.rus_name : animeData.name; + presenceData.largeImageText = title; presenceData.buttons = [ { label: "Открыть аниме", From 8b31978d9913ddf73fa99e151132498ef3b99677 Mon Sep 17 00:00:00 2001 From: Kitosight Date: Thu, 16 Jan 2025 00:52:37 +0300 Subject: [PATCH 3/3] chore(AnimeLib): remove unnecessary comment --- websites/A/AnimeLib/presence.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/websites/A/AnimeLib/presence.ts b/websites/A/AnimeLib/presence.ts index 7ec7ae972399..20253257b26b 100644 --- a/websites/A/AnimeLib/presence.ts +++ b/websites/A/AnimeLib/presence.ts @@ -127,8 +127,6 @@ presence.on("UpdateData", async () => { const title = animeData.rus_name !== "" ? animeData.rus_name : animeData.name; - // presenceData.details = - // animeData.rus_name !== "" ? animeData.rus_name : animeData.name; titleSetting ? (presenceData.name = title) : (presenceData.details = title);