Skip to content

Commit d1aeaf8

Browse files
committed
feat: ✨ 支持 HentaiZap
#254
1 parent 3ab2272 commit d1aeaf8

5 files changed

Lines changed: 41 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
209209
- [kemono](https://kemono.su)
210210
- [nekohouse](https://nekohouse.su)
211211
- [welovemanga](https://welovemanga.one)
212+
- [HentaiZap](https://hentaizap.com)
212213
- [Tachidesk](https://github.com/Suwayomi/Tachidesk-Sorayomi)
213214

214215
<!-- supportSiteList -->

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
209209
- [kemono](https://kemono.su)
210210
- [nekohouse](https://nekohouse.su)
211211
- [welovemanga](https://welovemanga.one)
212+
- [HentaiZap](https://hentaizap.com)
212213
- [Tachidesk](https://github.com/Suwayomi/Tachidesk-Sorayomi)
213214

214215
<!-- supportSiteList -->

src/helper/other.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ export { createScheduled } from '@solid-primitives/scheduled';
99

1010
export { default as isEqual } from 'fast-deep-equal/es6/index.js';
1111

12+
/** 图片文件扩展名缩写 */
13+
export const fileType = {
14+
j: 'jpg',
15+
p: 'png',
16+
g: 'gif',
17+
w: 'webp',
18+
b: 'bmp',
19+
} as const;
20+
1221
export const throttle: ScheduleCallback = (fn, wait = 100) =>
1322
leadingAndTrailing(_throttle, fn, wait);
1423

src/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
waitDom,
1717
requestIdleCallback,
1818
debounce,
19+
fileType,
1920
} from 'helper';
2021
import {
2122
request,
@@ -916,6 +917,27 @@ try {
916917
break;
917918
}
918919

920+
// #[HentaiZap](https://hentaizap.com)
921+
case 'hentaizap.com': {
922+
if (!location.pathname.startsWith('/g/')) break;
923+
924+
options = {
925+
name: 'hentaizap',
926+
getImgList() {
927+
const max = Number(querySelector<HTMLInputElement>('#pages')!.value);
928+
const img = querySelector<HTMLImageElement>('#fimg')!;
929+
const imgUrl = img.dataset.src || img.src;
930+
const baseUrl = imgUrl.split('/').slice(0, -1).join('/');
931+
return range(
932+
max,
933+
(i) =>
934+
`${baseUrl}/${i + 1}.${fileType[unsafeWindow.g_th[i + 1].slice(0, 1)]}`,
935+
);
936+
},
937+
};
938+
break;
939+
}
940+
919941
// 为 pwa 版页面提供 api,以便翻译功能能正常运作
920942
// case 'localhost':
921943
case 'comic-read.pages.dev': {

src/site/ehentai/crossSiteLink.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { request, toast } from 'main';
2-
import { t, querySelector, plimit, hijackFn, querySelectorAll } from 'helper';
2+
import {
3+
t,
4+
querySelector,
5+
plimit,
6+
hijackFn,
7+
querySelectorAll,
8+
fileType,
9+
} from 'helper';
310
import { For, Show, type Component, type JSX } from 'solid-js';
411
import { render } from 'solid-js/web';
512
import { createStore } from 'solid-js/store';
@@ -28,13 +35,6 @@ const nhentai = async ({
2835
}
2936

3037
// nhentai api 对应的扩展名
31-
const fileType = {
32-
j: 'jpg',
33-
p: 'png',
34-
g: 'gif',
35-
w: 'webp',
36-
b: 'bmp',
37-
} as const;
3838

3939
// 只要带上 cf_clearance cookie 就能通过 Cloudflare 验证,但其是 httpOnly
4040
// 目前暴力猴还不支持 GM_Cookie,篡改猴也需要去设置里手动设置才能支持 httpOnly

0 commit comments

Comments
 (0)