Skip to content

Commit 2ec97c8

Browse files
committed
BUILD 1.1.3
1 parent 9d1abd1 commit 2ec97c8

3 files changed

Lines changed: 290 additions & 122 deletions

File tree

anilist.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
async function loadAniList() {
2+
const query = `
3+
query {
4+
MediaListCollection(
5+
userName: "notmithun",
6+
type: ANIME,
7+
status: CURRENT
8+
) {
9+
lists {
10+
entries {
11+
progress
12+
media {
13+
episodes
14+
title {
15+
english
16+
romaji
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}
23+
`;
24+
25+
try {
26+
const response = await fetch("https://graphql.anilist.co", {
27+
method: "POST",
28+
headers: {
29+
"Content-Type": "application/json",
30+
Accept: "application/json",
31+
},
32+
body: JSON.stringify({ query }),
33+
});
34+
35+
const data = await response.json();
36+
37+
const anime =
38+
data?.data?.MediaListCollection?.lists
39+
?.flatMap((list) => list.entries)
40+
?.map((entry) => {
41+
const title = entry.media.title.english || entry.media.title.romaji;
42+
43+
const current = entry.progress ?? "?";
44+
const total = entry.media.episodes ?? "?";
45+
46+
return `${title} (${current}/${total})`;
47+
}) || [];
48+
49+
document.getElementById("anime_watching_now").textContent = anime.length
50+
? anime.join(", ")
51+
: "Nothing right now";
52+
} catch (err) {
53+
document.getElementById("anime_watching_now").textContent =
54+
"Unable to load";
55+
console.error(err);
56+
}
57+
}
58+
59+
loadAniList();

assets/anilist.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)