Skip to content

Commit

Permalink
feat: ✨ 增加 ehentai 快捷评分功能
Browse files Browse the repository at this point in the history
  • Loading branch information
hymbz committed Jul 7, 2024
1 parent 44cb4ea commit 55889d2
Show file tree
Hide file tree
Showing 12 changed files with 251 additions and 38 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
- 解锁隐藏漫画
- [ehentai](https://e-hentai.org)
- [关联 nhentai](#关联-nhentai)
- [快捷键翻页](#快捷键翻页)
- [快捷收藏](#快捷收藏)
- [识别广告](#识别广告)
- [标签染色](#标签染色)
- [识别广告页](#识别广告页)
- [快捷评分](#快捷评分)
- [快捷键翻页](#快捷键翻页)
- [nhentai](https://nhentai.net)
- [彻底屏蔽漫画](#彻底屏蔽漫画)
- [自动翻页](#自动翻页)
- [无限滚动](#无限滚动)
- [Yurifans](https://www.yurifans.com)
- 自动签到
- [拷贝漫画](https://www.copymanga.com)
Expand Down Expand Up @@ -226,16 +228,20 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h

> 标签颜色数据将在 `进入「My Tags」时``在「My Tags」中修改后` 更新
### 快捷键翻页

在漫画列表页和详情页增加通过左右方向键翻页的功能。

### 识别广告
### 识别广告页

简单识别下广告页并自动排除,只会在有`extraneous ads(外部广告)`标签时生效。如果你有用 Hath Perks 购买了 `More Thumbs(更多缩略图)` 的话,可以通过调大缩略图行数来略微加快一点识别速度。

如有误杀还请先反馈,然后可以先在右下角的悬浮按钮菜单里关闭该功能,等脚本更新修复后再开启。

### 快捷评分

让列表页显示的评分不再只是摆设,而是和详情页一样可以直接点击修改。

### 快捷键翻页

在列表页和详情页使用左右方向键翻页。

## nhentai

除悬浮按钮外,也会在右侧边栏会增加一个「Load comic」按钮,功能和悬浮按钮一样。
Expand All @@ -244,9 +250,9 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h

nhentai 的屏蔽机制是在被屏蔽漫画封面加上一层半透明遮罩,所以对于那些屏蔽范围比较大的人来说,在首页或搜索结果里连续翻上几页都是满屏的被屏蔽漫画完全是家常便饭。开启此功能后,被屏蔽漫画将被彻底屏蔽,不会再出现在首页或搜索结果里了。

> 开启此功能后可能出现一整页的漫画都被屏蔽的情况,为此有了自动翻页功能
> 开启此功能后可能出现一整页的漫画都被屏蔽的情况,为此有了无限滚动功能
### 自动翻页
### 无限滚动

当网页滚动至底部时将自动在底部加载下一页的内容,加载时底部会有加载条表示正在加载,当加载条停止时表示已到最后页。

Expand Down
26 changes: 16 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h
- 解锁隐藏漫画
- [ehentai](https://e-hentai.org)
- [关联 nhentai](#关联-nhentai)
- [快捷键翻页](#快捷键翻页)
- [快捷收藏](#快捷收藏)
- [识别广告](#识别广告)
- [标签染色](#标签染色)
- [识别广告页](#识别广告页)
- [快捷评分](#快捷评分)
- [快捷键翻页](#快捷键翻页)
- [nhentai](https://nhentai.net)
- [彻底屏蔽漫画](#彻底屏蔽漫画)
- [自动翻页](#自动翻页)
- [无限滚动](#无限滚动)
- [Yurifans](https://www.yurifans.com)
- 自动签到
- [拷贝漫画](https://www.copymanga.com)
Expand Down Expand Up @@ -226,16 +228,20 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h

> 标签颜色数据将在 `进入「My Tags」时``在「My Tags」中修改后` 更新
### 快捷键翻页

在漫画列表页和详情页增加通过左右方向键翻页的功能。

### 识别广告
### 识别广告页

简单识别下广告页并自动排除,只会在有`extraneous ads(外部广告)`标签时生效。如果你有用 Hath Perks 购买了 `More Thumbs(更多缩略图)` 的话,可以通过调大缩略图行数来略微加快一点识别速度。

如有误杀还请先反馈,然后可以先在右下角的悬浮按钮菜单里关闭该功能,等脚本更新修复后再开启。

### 快捷评分

让列表页显示的评分不再只是摆设,而是和详情页一样可以直接点击修改。

### 快捷键翻页

在列表页和详情页使用左右方向键翻页。

## nhentai

除悬浮按钮外,也会在右侧边栏会增加一个「Load comic」按钮,功能和悬浮按钮一样。
Expand All @@ -244,9 +250,9 @@ Cotrans 也有自己的油猴脚本 —— 「[Cotrans 漫画/图片翻译器](h

nhentai 的屏蔽机制是在被屏蔽漫画封面加上一层半透明遮罩,所以对于那些屏蔽范围比较大的人来说,在首页或搜索结果里连续翻上几页都是满屏的被屏蔽漫画完全是家常便饭。开启此功能后,被屏蔽漫画将被彻底屏蔽,不会再出现在首页或搜索结果里了。

> 开启此功能后可能出现一整页的漫画都被屏蔽的情况,为此有了自动翻页功能
> 开启此功能后可能出现一整页的漫画都被屏蔽的情况,为此有了无限滚动功能
### 自动翻页
### 无限滚动

当网页滚动至底部时将自动在底部加载下一页的内容,加载时底部会有加载条表示正在加载,当加载条停止时表示已到最后页。

Expand Down
7 changes: 5 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,23 @@
"site": {
"add_feature": {
"associate_nhentai": "Associate nhentai",
"auto_page_turn": "Auto page turning",
"auto_page_turn": "Infinite scroll",
"block_totally": "Totally block comics",
"colorize_tag": "Colorize tags",
"detect_ad": "Detect advertise page",
"hotkeys_page_turn": "Page turning with hotkeys",
"load_original_image": "Load original image",
"open_link_new_page": "Open links in a new page",
"quick_favorite": "Quick favorite",
"quick_rating": "Quick rating",
"remember_current_site": "Remember the current site"
},
"changed_load_failed": "The website has undergone changes, unable to load comics",
"ehentai": {
"change_favorite_failed": "Failed to change the favorite",
"change_favorite_success": "Favorite change success",
"change_favorite_success": "Successfully changed the favorite",
"change_rating_failed": "Failed to change the rating",
"change_rating_success": "Successfully changed the rating",
"fetch_favorite_failed": "Failed to get favorite info",
"fetch_img_page_source_failed": "Failed to get the source code of the image page",
"fetch_img_page_url_failed": "Failed to get the image page address from the detail page",
Expand Down
5 changes: 4 additions & 1 deletion locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@
"load_original_image": "Загружать оригинальное изображение",
"open_link_new_page": "Открывать ссылки в новой вкладке",
"quick_favorite": "Быстрый фаворит",
"quick_rating": "Быстрый рейтинг",
"remember_current_site": "Запомнить текущий сайт"
},
"changed_load_failed": "Страница изменилась, невозможно загрузить комикс",
"ehentai": {
"change_favorite_failed": "Не удалось изменить избранное",
"change_favorite_success": "Любимый успех изменений",
"change_favorite_success": "Избранное успешно изменено",
"change_rating_failed": "Не удалось изменить оценку",
"change_rating_success": "Успешно изменен рейтинг",
"fetch_favorite_failed": "Не удалось получить информацию о избранном",
"fetch_img_page_source_failed": "Не удалось получить исходный код страницы с изображениями",
"fetch_img_page_url_failed": "Не удалось получить адрес страницы изображений из деталей",
Expand Down
5 changes: 4 additions & 1 deletion locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,23 @@
"site": {
"add_feature": {
"associate_nhentai": "关联nhentai",
"auto_page_turn": "自动翻页",
"auto_page_turn": "无限滚动",
"block_totally": "彻底屏蔽漫画",
"colorize_tag": "标签染色",
"detect_ad": "识别广告页",
"hotkeys_page_turn": "快捷键翻页",
"load_original_image": "加载原图",
"open_link_new_page": "在新页面中打开链接",
"quick_favorite": "快捷收藏",
"quick_rating": "快捷评分",
"remember_current_site": "记住当前站点"
},
"changed_load_failed": "网站发生变化,无法加载漫画",
"ehentai": {
"change_favorite_failed": "收藏夹修改失败",
"change_favorite_success": "收藏夹修改成功",
"change_rating_failed": "评分修改失败",
"change_rating_success": "评分修改成功",
"fetch_favorite_failed": "获取收藏夹信息失败",
"fetch_img_page_source_failed": "获取图片页源码失败",
"fetch_img_page_url_failed": "从详情页获取图片页地址失败",
Expand Down
12 changes: 11 additions & 1 deletion metaHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ export const updateReadme = () => {
if (newOutMd !== outMd) fs.writeFileSync(outMdPath, newOutMd);
};

const enSupportSite = [
'E-Hentai (Associate nhentai, Quick favorite, Colorize tags, Detect advertise page, etc.)',
'nhentai (Totally block comics, Auto page turning)',
'hitomi',
'Anchira',
'kemono',
'nekohouse',
'welovemanga',
];

/** 脚本头部注释 */
export const getMetaData = (isDevMode: boolean) => {
const meta = {
Expand All @@ -84,7 +94,7 @@ export const getMetaData = (isDevMode: boolean) => {
description: `${zh.description}${getSupportSiteList()
.map((site) => site.replace(/\[(.+)]\(.+\)/, '$1'))
.join('、')}`,
'description:en': en.description,
'description:en': `${en.description} ${enSupportSite.join(' | ')}.`,
'description:ru': ru.description,
author: pkg.author,
license: pkg.license,
Expand Down
7 changes: 7 additions & 0 deletions src/components/Manga/components/ComicImg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ export const ComicImg: Component<ComicImg & { index: number }> = (img) => (
fallback={SaveComicImg(img)}
/>
);

// 目前即使是不显示的图片也必须挂载上,否则解析好的图片会被浏览器垃圾回收掉,
// 导致在 ehentai 上无法正常加载图片。但这样会在图片过多时造成性能问题,
// 虽然也尝试了将解析好的 Image 对象存储起来挂上引用和另外放到一个避免渲染的 dom 下,
// 但也都失败了,只能暂时先不管了。
// 之后尝试新方案时必须经过如下测试:开个几百页的漫画加载完毕后,再打开二十个标签页切换过去,
// 等待一分钟再切回来,等待一小时后再切回来
6 changes: 5 additions & 1 deletion src/helper/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const request = async <T = any>(
const headers = { Referer: window.location.href };
const errorText = `${
details?.errorText ?? t('alert.comic_load_error')
} - ${url}`;
}\nurl: ${url}`;

try {
// 虽然 GM_xmlhttpRequest 有 fetch 选项,但在 stay 上不太稳定
Expand All @@ -56,6 +56,10 @@ export const request = async <T = any>(
body: details?.data,
signal: AbortSignal.timeout?.(details?.timeout ?? 1000 * 10),
});
if (!details?.noCheckCode && res.status !== 200) {
log.error(errorText, res);
throw new Error(errorText);
}

let response = null as T;
switch (details?.responseType) {
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const main = require('main') as typeof import('./main');
try {
// 匹配站点
switch (window.location.hostname) {
// #百合会——「记录阅读历史、自动签到等
// #百合会记录阅读历史、自动签到等
case 'bbs.yamibo.com': {
inject('yamibo');
break;
Expand Down Expand Up @@ -75,7 +75,7 @@ try {
break;
}

// #动漫之家——「解锁隐藏漫画
// #动漫之家解锁隐藏漫画
case 'comic.idmzj.com':
case 'comic.dmzj.com':
case 'manhua.idmzj.com':
Expand All @@ -96,26 +96,26 @@ try {
break;
}

// #E-Hentai——「匹配 nhentai 漫画」
// #E-Hentai(关联 nhentai、快捷收藏、标签染色、识别广告页等)
case 'exhentai.org':
case 'e-hentai.org': {
inject('ehentai');
break;
}

// #nhentai——「彻底屏蔽漫画、自动翻页」
// #nhentai彻底屏蔽漫画、无限滚动)
case 'nhentai.net': {
inject('nhentai');
break;
}

// #Yurifans——「自动签到
// #Yurifans自动签到
case 'yuri.website': {
inject('yurifans');
break;
}

// #拷贝漫画(copymanga)——「显示最后阅读记录
// #拷贝漫画(copymanga)显示最后阅读记录
case 'mangacopy.com':
case 'copymanga.site':
case 'copymanga.info':
Expand Down
29 changes: 24 additions & 5 deletions src/site/ehentai/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,37 @@ import {
getAdPageByFileName,
getAdPageByContent,
ReactiveSet,
requestIdleCallback,
} from 'main';

import { quickFavorite } from './quickFavorite';
import { associateNhentai } from './associateNhentai';
import { hotkeysPageTurn } from './hotkeys';
import { colorizeTag } from './ColorizeTag';

export type PageType = 'gallery' | 'mytags' | 't' | 'e' | undefined;
import { quickRating } from './quickRating';

type ListPageType =
/** 最小化 */
| 'm'
/** 最小化 + 关注标签 */
| 'p'
/** 紧凑 + 标签 */
| 'l'
/** 扩展 */
| 'e'
/** 缩略图 */
| 't';

export type PageType = 'gallery' | 'mytags' | ListPageType;

(async () => {
let pageType: PageType;
let pageType: PageType | undefined;

if (Reflect.has(unsafeWindow, 'display_comment_field')) pageType = 'gallery';
else if (location.pathname === '/mytags') pageType = 'mytags';
else
pageType = querySelector<HTMLSelectElement>('#ujumpbox ~ div > select')
?.value as PageType;
?.value as PageType | undefined;

if (!pageType) return;

Expand All @@ -50,12 +64,14 @@ export type PageType = 'gallery' | 'mytags' | 't' | 'e' | undefined;
associate_nhentai: true,
/** 快捷键翻页 */
hotkeys_page_turn: true,
/** 识别广告 */
/** 识别广告页 */
detect_ad: true,
/** 快捷收藏 */
quick_favorite: true,
/** 标签染色 */
colorize_tag: false,
/** 快捷评分 */
quick_rating: true,
autoShow: false,
});

Expand Down Expand Up @@ -85,6 +101,9 @@ export type PageType = 'gallery' | 'mytags' | 't' | 'e' | undefined;
if (options.colorize_tag) colorizeTag(pageType);
// 快捷键翻页
if (options.hotkeys_page_turn) hotkeysPageTurn(pageType);
// 快捷评分
if (options.quick_rating)
requestIdleCallback(() => quickRating(pageType), 1000);
// 快捷收藏。必须处于登录状态
if (unsafeWindow.apiuid !== -1 && options.quick_favorite)
quickFavorite(pageType);
Expand Down
Loading

0 comments on commit 55889d2

Please sign in to comment.