From 6a850e70090beadf8c1a43bc9d177c70e2f4908c Mon Sep 17 00:00:00 2001 From: sinkaroid Date: Fri, 12 Aug 2022 02:27:19 +0700 Subject: [PATCH] fix(modifier): apply fixes for nhentai random --- src/utils/modifier.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/utils/modifier.ts b/src/utils/modifier.ts index 3875f17..6d72d94 100644 --- a/src/utils/modifier.ts +++ b/src/utils/modifier.ts @@ -83,13 +83,19 @@ export async function getIdRandomPururin (): Promise { } export async function getIdRandomNhentai (): Promise { - const res: any = await p({ - url: `${c.NHENTAI}/random`, - followRedirects: true, - }); - - const getId = res.socket._httpMessage.path; - return parseInt(getId.replace(/^\/g\/([0-9]+)\/?$/, "$1")); + if (await mock(c.NHENTAI)) { + const res: any = await p({ + url: `${c.NHENTAI}/random`, + followRedirects: true, + }); + + const getId = res.socket._httpMessage.path; + return parseInt(getId.replace(/^\/g\/([0-9]+)\/?$/, "$1")); + } else { + const end = 1234; + const start = 567890; + return Math.floor(Math.random() * (end - start + 1)) + start; + } }