Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(AnimeLib): cache current dub #9165

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions websites/A/AnimeLib/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,36 @@
"ru": "Смотрите аниме онлайн на русском"
},
"url": "anilib.me",
"version": "1.0.5",
"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",
"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",
"icon": "fas fa-compress-arrows-alt",
"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
}
]
}
}
27 changes: 20 additions & 7 deletions websites/A/AnimeLib/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<boolean>("privacy"),
presence.getSetting<boolean>("buttons"),
presence.getSetting<boolean>("titleAsPresence"),
]),
path = document.location.pathname;

Expand Down Expand Up @@ -115,15 +116,27 @@ presence.on("UpdateData", async () => {
.querySelectorAll(".btn.is-outline")[7]
?.querySelector("span")?.textContent;

if (dub) {
presenceData.details =
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;

const title =
animeData.rus_name !== "" ? animeData.rus_name : animeData.name;

// presenceData.details =
// animeData.rus_name !== "" ? animeData.rus_name : animeData.name;
Kitosight marked this conversation as resolved.
Show resolved Hide resolved
titleSetting
? (presenceData.name = title)
: (presenceData.details = title);
presenceData.state = `${
episode ? (episode.includes("эпизод") ? episode : "Фильм") : "Фильм"
} | ${dub}`;
} | ${currentDub}`;
presenceData.largeImageKey = animeData.cover.default;
presenceData.largeImageText =
animeData.rus_name !== "" ? animeData.rus_name : animeData.name;
presenceData.largeImageText = title;
presenceData.buttons = [
{
label: "Открыть аниме",
Expand Down
Loading