Skip to content

Commit 83ee0dd

Browse files
authored
Merge pull request #287 from EnergoStalin/feat/nude-moon
feat: add nude-moon support
2 parents eab7f3b + 5844712 commit 83ee0dd

5 files changed

Lines changed: 62 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
210210
- [熱辣漫畫](https://www.relamanhua.org/)
211211
- [hitomi](https://hitomi.la)
212212
- [SchaleNetwork](https://schale.network/)
213+
- [nude-moon](https://nude-moon.org)
213214
- [kemono](https://kemono.su)
214215
- [nekohouse](https://nekohouse.su)
215216
- [welovemanga](https://welovemanga.one)

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
210210
- [熱辣漫畫](https://www.relamanhua.org/)
211211
- [hitomi](https://hitomi.la)
212212
- [SchaleNetwork](https://schale.network/)
213+
- [nude-moon](https://nude-moon.org)
213214
- [kemono](https://kemono.su)
214215
- [nekohouse](https://nekohouse.su)
215216
- [welovemanga](https://welovemanga.one)

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,13 @@ try {
819819
break;
820820
}
821821

822+
// #[nude-moon](https://nude-moon.org)
823+
// test: https://nude-moon.org/22729--zone-himitsu-no-tomodachi--tayney-drug.html
824+
case 'nude-moon.org': {
825+
inject('site/nude-moon');
826+
break;
827+
}
828+
822829
// #[kemono](https://kemono.su)
823830
// test: https://kemono.cr/fanbox/user/41106591/post/6813818
824831
case 'kemono.cr':

src/rollup-plugin/metaHeader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const enSupportSite = [
8585
'hitomi',
8686
'Anchira',
8787
'kemono',
88+
'nude-moon',
8889
'nekohouse',
8990
'welovemanga',
9091
];

src/site/nude-moon.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { hotkeysMap } from 'components/Manga';
2+
import {
3+
domParse,
4+
getKeyboardCode,
5+
linstenKeydown,
6+
querySelectorClick,
7+
} from 'helper';
8+
import { useInit } from 'main';
9+
10+
(async () => {
11+
const isMangaPage = () => location.pathname.match(/^\/\d+-/) !== null;
12+
13+
const original = async () => {
14+
const url = new URL(location.href);
15+
const parts = url.pathname.split('-');
16+
parts.splice(1, 0, 'online');
17+
url.pathname = parts.join('-');
18+
19+
const html = await fetch(url).then((e) => e.text());
20+
const doc = domParse(html);
21+
22+
const script = [...doc.querySelectorAll('script')].find((e) =>
23+
e.textContent.includes('/manga/'),
24+
);
25+
if (!script) return [];
26+
27+
return Array.from(
28+
script.textContent.matchAll(/\/manga\/[^']+/g),
29+
(e) => `https://nude-moon.org${e[0]}`,
30+
);
31+
};
32+
33+
const { setState } = await useInit('nude-moon', {
34+
autoShow: false,
35+
defaultOption: { pageNum: 1 },
36+
});
37+
38+
setState((state) => {
39+
if (isMangaPage()) state.comicMap[''].getImgList = original;
40+
});
41+
42+
linstenKeydown((e) => {
43+
switch (hotkeysMap()[getKeyboardCode(e)]) {
44+
case 'scroll_right':
45+
e.preventDefault();
46+
return querySelectorClick('a.small', 'Следующая')?.();
47+
case 'scroll_left':
48+
e.preventDefault();
49+
return querySelectorClick('a.small', 'Предыдущая')?.();
50+
}
51+
});
52+
})();

0 commit comments

Comments
 (0)