Skip to content

Commit

Permalink
feat(Tio Anime): add watching type and make code more readable (#8583)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark_Ville authored Jul 21, 2024
1 parent 4d5d769 commit 7b9c5f7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion websites/T/Tio Anime/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"es": "El mejor portal para ver anime online sub español en calidad HD, descargar anime ligero en HD desde Mega, Mediafire y más! TioAnime tu mejor opción."
},
"url": "tioanime.com",
"version": "1.0.19",
"version": "1.1.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/thumbnail.png",
"color": "#18142f",
Expand Down
99 changes: 50 additions & 49 deletions websites/T/Tio Anime/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,61 @@ presence.on("UpdateData", async () => {
"https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/logo.png",
startTimestamp: browsingTimestamp,
},
privacy = await presence.getSetting<boolean>("privacy"),
buttons = await presence.getSetting<boolean>("buttons");
[privacy, buttons] = await Promise.all([
presence.getSetting<boolean>("privacy"),
presence.getSetting<string>("buttons"),
]),
{ href, pathname } = document.location;

if (document.location.pathname === "/")
presenceData.details = "En la página de inicio";
else if (document.location.pathname.includes("/anime/")) {
if (pathname === "/") presenceData.details = "En la página de inicio";
else if (pathname.includes("/anime/")) {
if (!privacy) {
if (buttons) {
presenceData.buttons = [
{
label: "Ver Anime",
url: document.URL,
},
];
}
presenceData.buttons = [
{
label: "Ver Anime",
url: href,
},
];
presenceData.details = "Viendo lista de episodios:";
presenceData.state = document.querySelector(".title").textContent;
} else presenceData.details = "Viendo lista de episodios";
} else if (document.location.pathname.includes("/ver/")) {
if (!privacy) {
if (buttons) {
presenceData.buttons = [
{
label: "Ver Capítulo",
url: document.URL,
},
];
}
const capt = document.querySelector("h1").textContent;
presenceData.details = "Viendo Anime:";
presenceData.state = `${capt.substring(
0,
document.querySelector("h1").textContent.lastIndexOf(" ")
)} capítulo ${capt.split(" ").pop()}`;
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestamps(
Math.floor(video.currentTime),
Math.floor(video.duration)
);
presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play;
presenceData.smallImageText = video.paused
? "Capítulo pausado"
: "Reproduciendo capítulo";
if (video.paused) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
} else {
presenceData.details = "Viendo anime";
presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play;
presenceData.smallImageText = video.paused
? "Capítulo pausado"
: "Reproduciendo capítulo";
} else if (pathname.includes("/ver/")) {
presenceData.type = ActivityType.Watching;
presenceData.buttons = [
{
label: "Ver Capítulo",
url: href,
},
];
const capt = document.querySelector("h1").textContent;
presenceData.details = "Viendo Anime:";
presenceData.state = `${capt.substring(
0,
document.querySelector("h1").textContent.lastIndexOf(" ")
)} capítulo ${capt.split(" ").pop()}`;
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestamps(
Math.floor(video.currentTime),
Math.floor(video.duration)
);
presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play;
presenceData.smallImageText = video.paused
? "Capítulo pausado"
: "Reproduciendo capítulo";
if (video.paused) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
} else {
presenceData.type = ActivityType.Watching;
presenceData.details = "Viendo anime";
presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play;
presenceData.smallImageText = video.paused
? "Capítulo pausado"
: "Reproduciendo capítulo";
}
switch (document.location.pathname) {

switch (pathname) {
case "/directorio":
presenceData.details = "Viendo el directorio de animes";
break;
Expand All @@ -89,6 +88,8 @@ presence.on("UpdateData", async () => {
break;
}

if ((privacy || !buttons) && presenceData.buttons)
delete presenceData.buttons;
if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
});

0 comments on commit 7b9c5f7

Please sign in to comment.