diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index 271901a5..7278876f 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -25,11 +25,21 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { arn.diff(`${root.dataset.url}/${year}/${season}/${status}/${type}`) } -// Hides anime that are already in your list. -export function hideAddedAnime() { - for(let anime of findAll("anime-grid-cell")) { - if(anime.dataset.added === "true") { - anime.classList.toggle("anime-grid-cell-hide") +// Hides anime that are already in your list. And "toggles" localStorage.hide if button is pressed +export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLButtonElement) { + if(input) { + if(localStorage.getItem("hide-added-anime") === "true") { + localStorage.setItem("hide-added-anime", "false") + } else { + localStorage.setItem("hide-added-anime", "true") + } + } + + if(input || localStorage.getItem("hide-added-anime") === "true") { + for(let anime of findAll("anime-grid-cell")) { + if(anime.dataset.added === "true") { + anime.classList.toggle("anime-grid-cell-hide") + } } } } diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index ec86f409..4b3563ef 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -164,7 +164,8 @@ export default class AnimeNotifier { Promise.resolve().then(() => this.dragAndDrop()), Promise.resolve().then(() => this.colorStripes()), Promise.resolve().then(() => this.assignTooltipOffsets()), - Promise.resolve().then(() => this.countUp()) + Promise.resolve().then(() => this.countUp()), + Promise.resolve().then(() => this.hideAddedAnime()) ]) // Apply page title @@ -473,6 +474,17 @@ export default class AnimeNotifier { } } + // Hides user anime automatically if localStorage.hide is true + hideAddedAnime() { + if(!this.app.currentPath.includes("/explore") && !this.app.currentPath.includes("/genre")) { + return + } + + if(localStorage.getItem("hide-added-anime") === "true") { + actions.hideAddedAnime() + } + } + markPlayingSoundTrack() { for(let element of findAll("soundtrack-play-area")) { if(element.dataset.soundtrackId === this.currentSoundTrackId) {