Skip to content

Commit

Permalink
ya
Browse files Browse the repository at this point in the history
  • Loading branch information
hammyo-o authored Nov 18, 2024
1 parent c66a60e commit e451bd4
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions 0.8/NHentai/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
}));
Expand Down Expand Up @@ -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() {
Expand All @@ -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: [],
Expand Down Expand Up @@ -1380,15 +1393,18 @@ 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
}
});
}
}
async getHomePageSections(sectionCallback) {
const skipReadManga = await this.stateManager.retrieve("skip_read_manga") ?? false;
const readMangaIds = skipReadManga ? await this.getReadMangaIds() : [];
const sections = [
{
request: App.createRequest({
Expand Down Expand Up @@ -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);
})
);
Expand All @@ -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"
Expand All @@ -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
}
Expand Down Expand Up @@ -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);
})();
Expand Down

0 comments on commit e451bd4

Please sign in to comment.