Skip to content

Commit

Permalink
feat(AniList): add buttons setting and fix user avatar (PreMiD#6784)
Browse files Browse the repository at this point in the history
* feat(AniList): add `buttons` setting and fix user avatar

* feat(AniList): apply suggested changes
  • Loading branch information
plskz authored Sep 16, 2022
1 parent 3194310 commit 9bf491f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion websites/A/AniList/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"vi_VN": "AniList: Theo dõi, tìm kiếm, chia sẻ Anime & Manga - Đăng ký ngay hôm nay!"
},
"url": "anilist.co",
"version": "2.0.2",
"version": "2.1.0",
"logo": "https://i.imgur.com/fqyhsZ5.png",
"thumbnail": "https://i.imgur.com/ooIBlD5.jpg",
"color": "#02A9FF",
Expand All @@ -39,6 +39,12 @@
"title": "Show Cover",
"icon": "fad fa-images",
"value": true
},
{
"id": "buttons",
"title": "Show Buttons",
"icon": "fad fa-compress-arrows-alt",
"value": true
}
]
}
17 changes: 11 additions & 6 deletions websites/A/AniList/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ presence.on("UpdateData", async () => {
},
pathnameArray = document.location.pathname.split("/"),
page = pathnameArray[1],
showCover = await presence.getSetting<boolean>("cover");
[showCover, showButton] = await Promise.all([
presence.getSetting<boolean>("cover"),
presence.getSetting<boolean>("buttons"),
]);
strings = await getStrings();

switch (page) {
case "":
presenceData.details = strings.browsing;
presenceData.state = "Home";
break;
case "user": {
if (showCover) {
presenceData.largeImageKey = document
.querySelector(".avatar")
.querySelectorAll(".avatar")[1]
.getAttribute("src");
presenceData.smallImageKey = "anilist_lg";
}
Expand Down Expand Up @@ -145,7 +144,13 @@ presence.on("UpdateData", async () => {
case "settings":
presenceData.details = "Changing settings";
break;
default:
presenceData.details = strings.browsing;
presenceData.state = "Home";
break;
}

if (!showButton) delete presenceData.buttons;

presence.setActivity(presenceData, true);
});

0 comments on commit 9bf491f

Please sign in to comment.