From e451bd4beaec1ba896375c6d472bebc2ddbe111d Mon Sep 17 00:00:00 2001 From: pisshammy <165633434+hammyo-o@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:08:11 -0600 Subject: [PATCH] ya --- 0.8/NHentai/source.js | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/0.8/NHentai/source.js b/0.8/NHentai/source.js index 944929d..752c6a2 100644 --- a/0.8/NHentai/source.js +++ b/0.8/NHentai/source.js @@ -841,7 +841,8 @@ var _Sources = (() => { const artist = getArtist(data); const tags = []; for (const tag of data.tags) { - if (tag.type !== "tag") continue; + if (tag.type !== "tag") + continue; tags.push(App.createTag({ id: tag.name, label: capitalizeTags(tag.name) })); } return App.createSourceManga({ @@ -884,7 +885,8 @@ var _Sources = (() => { throw new Error("JSON NO RESULT ERROR!\n\nYou've like set too many additional arguments in this source's settings, remove some to see results!\nSo search with tags you need to use arguments like shown in the sourc's settings!"); } for (const gallery of data.result) { - if (collectedIds.includes(gallery.id.toString())) continue; + if (collectedIds.includes(gallery.id.toString())) + continue; tiles.push(App.createPartialSourceManga({ image: `https://t.nhentai.net/galleries/${gallery.media_id}/cover.${typeOfImage(gallery.images.cover)}`, title: gallery.title.pretty, @@ -1251,7 +1253,7 @@ var _Sources = (() => { // src/NHentai/NHentai.ts var NHENTAI_URL = "https://nhentai.net"; var NHentaiInfo = { - version: "4.0.8", + version: "4.0.81", name: "nhentai", icon: "icon.png", author: "NotMarek & Netsky", @@ -1297,7 +1299,15 @@ var _Sources = (() => { header: "Source Settings", rows: () => Promise.resolve([ settings(this.stateManager), - resetSettings(this.stateManager) + resetSettings(this.stateManager), + App.createDUISwitch({ + id: "skip_read_manga", + label: "Skip Read Manga", + value: App.createDUIBinding({ + get: async () => await this.stateManager.retrieve("skip_read_manga") ?? false, + set: async (newValue) => await this.stateManager.store("skip_read_manga", newValue) + }) + }) ]), isHidden: false })); @@ -1333,6 +1343,7 @@ var _Sources = (() => { const response = await this.requestManager.schedule(request, 1); this.CloudFlareError(response.status); const jsonData = this.parseJson(response); + await this.stateManager.store(`read_manga_${mangaId}`, true); return parseChapterDetails(jsonData, mangaId); } async getSearchTags() { @@ -1348,6 +1359,8 @@ var _Sources = (() => { async getSearchResults(query, metadata) { const page = metadata?.page ?? 1; const title = query.title ?? ""; + const skipReadManga = await this.stateManager.retrieve("skip_read_manga") ?? false; + const readMangaIds = skipReadManga ? await this.getReadMangaIds() : []; if (metadata?.stopSearch ?? false) { return App.createPagedResults({ results: [], @@ -1380,8 +1393,9 @@ var _Sources = (() => { const response = await this.requestManager.schedule(request, 1); this.CloudFlareError(response.status); const jsonData = this.parseJson(response); + const results = parseSearch(jsonData).filter(manga => !readMangaIds.includes(manga.mangaId)); return App.createPagedResults({ - results: parseSearch(jsonData), + results, metadata: { page: page + 1 } @@ -1389,6 +1403,8 @@ var _Sources = (() => { } } async getHomePageSections(sectionCallback) { + const skipReadManga = await this.stateManager.retrieve("skip_read_manga") ?? false; + const readMangaIds = skipReadManga ? await this.getReadMangaIds() : []; const sections = [ { request: App.createRequest({ @@ -1437,7 +1453,7 @@ var _Sources = (() => { if (hasNoResults(jsonData)) { return; } - section.sectionID.items = parseSearch(jsonData); + section.sectionID.items = parseSearch(jsonData).filter(manga => !readMangaIds.includes(manga.mangaId)); sectionCallback(section.sectionID); }) ); @@ -1446,6 +1462,8 @@ var _Sources = (() => { } async getViewMoreItems(homepageSectionId, metadata) { let page = metadata?.page ?? 1; + const skipReadManga = await this.stateManager.retrieve("skip_read_manga") ?? false; + const readMangaIds = skipReadManga ? await this.getReadMangaIds() : []; const request = App.createRequest({ url: `${NHENTAI_URL}/api/galleries/search?query=${await this.generateQuery()}&sort=${homepageSectionId}&page=${page}`, method: "GET" @@ -1454,8 +1472,9 @@ var _Sources = (() => { this.CloudFlareError(response.status); const jsonData = this.parseJson(response); page++; + const results = parseSearch(jsonData).filter(manga => !readMangaIds.includes(manga.mangaId)); return App.createPagedResults({ - results: parseSearch(jsonData), + results, metadata: { page } @@ -1506,6 +1525,10 @@ Please go to the homepage of <${_NHentai.name}> and press the cloud icon.`); const args = await getExtraArgs(stateManager); return ` ${args}`; } + async getReadMangaIds() { + const allData = await this.stateManager.retrieveAll(); + return Object.keys(allData).filter(key => key.startsWith("read_manga_")).map(key => key.replace("read_manga_", "")); + } }; return __toCommonJS(NHentai_exports); })();