Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复了69书吧 #651

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

一个**可扩展的**通用型小说下载器。

# 关于本Fork

本fork脚本下载:[bundle.user.js](https://github.com/ShenSheiBot/novel-downloader/raw/refs/heads/master/dist/bundle.user.js)

原作者已不再维护此仓库,此fork将继续维护,新增的功能包括:
- 允许跳过txt下载
- 支持了新飘天文学网(piaotia)
- 支持了xbookcn

修复的网站包括:
- Syosetu
- 69书吧
- Kakuyomu

如有需要修复/支持的网站,请在issue中提出。作者将在空闲时间内进行修复。


## 关于 404 小说文库项目

在这个 404 时代,由于种种原因,起点、晋江、刺猬猫、SF 等小说网站上的小说经常毫无征兆的消失。即使该小说已经入 V,即使你已经订阅了该小说。
Expand Down Expand Up @@ -156,12 +173,13 @@ EPUB 文件请使用相应阅读器阅读。
| [笔趣阁](http://www.b5200.net/) | ✅ | ❎ | |
| [言情小说](https://www.yqxsge.cc/) | ✅ | ❎ | |
| [18 看书](https://www.18kanshu.com/) | ✅ | ❎ | |
| [长篇X小说](https://book.xbookcn.net/) | ✅ | ❎ | |
| [笔下文学 333](http://www.bixia3.com/) | ✅ | ❎ | |
| [小说屋](http://www.xiaoshuowu.com/) | ✅ | ❎ | |
| [缤纷幻想](https://colorful-fantasybooks.com/) | ✅ | ❎ | |
| [弟子小说网](https://www.dizishu.com/xiaoshuo/) | ✅ | ❎ | |
| [新笔趣阁](https://www.ibiquge.la/) | ✅ | ❎ | |
| [69 书吧](https://www.69shu.com/) | ✅ | ❎ | |
| [69 书吧](https://69shuba.cx/) | ✅ | ❎ | |
| [笔下文学](https://www.ywggzy.com/) | ✅ | ❎ | |
| [飘天文学网](https://www.piaotia.com/) | ✅ | ❎ | |
| [红袖招](https://hongxiuzhao.me/) | ✅ | ❎ | |
Expand Down
357 changes: 357 additions & 0 deletions dist/bundle.user.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { GmWindow } from "./global";
import { _GM_info } from "./lib/GM";
import { storageAvailable } from "./lib/localStorageExpired";
import { enableDebug } from "./setting";
import { enableDebug, skipTxtDownload } from "./setting";
import { fetchWithRetry, fetchWithTimeout } from "./lib/http";

function checkObjct(name: string) {
Expand Down Expand Up @@ -84,6 +84,7 @@ export const environments = async () => {
Cookie: navigator.cookieEnabled,
doNotTrack: navigator.doNotTrack ?? 0,
enableDebug: enableDebug.value,
skipTxtDownload: skipTxtDownload.value,
ScriptHandler: _GM_info.scriptHandler,
"ScriptHandler version": _GM_info.version,
"Novel-downloader version": _GM_info.script.version,
Expand Down
7 changes: 5 additions & 2 deletions src/header.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@
"*://www.akatsuki-novels.com/stories/index/novel_id~*",
"*://www.alphapolis.co.jp/novel/*/*",
"*://novelup.plus/story/*",
"*://www.69shu.com/txt/*.htm",
"*://69shuba.cx/book/*.htm",
"*://book.xbookcn.net/search/label/*",
"*://new-read.readmoo.com/mooreader/*",
"*://www.iqingguo.com/book/detail/?id=*",
"*://www.ywggzy.com/bxwx/*/",
Expand All @@ -213,7 +214,9 @@
"*://www.42zw.la/book/*/",
"*://www.boqugew.com/shu/*/",
"*://www.qbtr.cc/*/*.html",
"*://b.guidaye.com/*/*/"
"*://b.guidaye.com/*/*/",
"*://www.esjzone.me/detail/*",
"*://www.esjzone.cc/detail/*"
],
"exclude": [
"*://www.jjwxc.net/onebook.php?novelid=*&chapterid=*",
Expand Down
15 changes: 13 additions & 2 deletions src/router/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,16 @@ export async function getRule(): Promise<BaseRuleClass> {
ruleClass = xiaoshuowu();
break;
}
case "www.69shu.com": {
const { c69shu } = await import("../rules/twoPage/69shu");
case "69shuba.cx": {
const { c69shu } = await import("../rules/onePageWithMultiIndexPage/69shu");
ruleClass = c69shu();
break;
}
case "book.xbookcn.net": {
const { xbookcn } = await import("../rules/onePageWithMultiIndexPage/xbookcn");
ruleClass = xbookcn();
break;
}
/* twoPage End */

/** mbtxt **/
Expand Down Expand Up @@ -607,6 +612,12 @@ export async function getRule(): Promise<BaseRuleClass> {
ruleClass = la42zw();
break;
}
case "www.esjzone.cc":
case "www.esjzone.me": {
const { esjzone } = await import("../rules/onePage/original/esjzone");
ruleClass = esjzone();
break;
}
/** 笔趣阁END **/

default: {
Expand Down
37 changes: 37 additions & 0 deletions src/rules/onePage/original/esjzone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { rm } from "../../../lib/dom";
import { mkRuleClass } from "../template";

export const esjzone = () =>
mkRuleClass({
bookUrl: document.location.href,
bookname: (
document.querySelector("h2") as HTMLElement
).innerText.trim(),
author: (
Array.from(document.querySelectorAll('ul.book-detail li')).find(
li => li.textContent && li.textContent.includes('作者:')
)?.querySelector('a') as HTMLAnchorElement | null
)?.innerText.trim() || "Unknown Author",
introDom: document.querySelector(".description") as HTMLElement,
introDomPatch: (dom) => dom,
additionalMetadatePatch: (additionalMetadate) => {
additionalMetadate.tags = Array.from(
document.querySelectorAll(
'section.widget-tags.m-t-20 a.tag'
)
).map((a) => (a as HTMLAnchorElement).innerText);
return additionalMetadate;
},
coverUrl: null,
aList: document.querySelectorAll('#chapterList a'),
getAName: (aElem) =>
(aElem as HTMLElement)?.innerText.trim(),
getContent: (dom) => dom.querySelector('.forum-content'),
contentPatch: (dom) => {
rm('h3', true, dom);
rm('footer', true, dom);
return dom;
},
language: "zh",
needLogin: true,
});
28 changes: 13 additions & 15 deletions src/rules/onePage/original/syosetu.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { rm } from "../../../lib/dom";
import { mkRuleClass } from "../template";

const currentPageIndexBox = document.querySelector('.index_box');
const currentPageIndexBox = document.querySelector('.p-eplist');

// Attempt to get the first and last page anchors
const firstPageAnchor = document.querySelector('.novelview_pager-first');
const lastPageAnchor = document.querySelector('.novelview_pager-last');
const firstPageAnchor = document.querySelector('.c-pager__item--first');
const lastPageAnchor = document.querySelector('.c-pager__item--last');

if (firstPageAnchor && lastPageAnchor) {
// Fallback to the current URL if href is null, it means we're on the last or first page
Expand All @@ -29,7 +29,7 @@ if (firstPageAnchor && lastPageAnchor) {
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const pageIndexBox = doc.querySelector('.index_box');
const pageIndexBox = doc.querySelector('.p-eplist');
if (pageIndexBox && currentPageIndexBox) {
const childrenArray = Array.from(pageIndexBox.children);
if (insertAfterCurrentBox) {
Expand Down Expand Up @@ -72,15 +72,15 @@ export const syosetu = () => {
};
const getAList = () => {
const _aList = document.querySelectorAll(
"dl.novel_sublist2 dd.subtitle > a"
"body > div.l-container > main > article > div.p-eplist > div > a"
);
if (_aList.length !== 0) {
return _aList;
} else {
const a = document.createElement("a");
a.href = document.location.href;
a.innerText = (
document.querySelector(".novel_title") as HTMLElement
document.querySelector(".p-novel__title") as HTMLElement
)?.innerText;
return [a];
}
Expand All @@ -94,26 +94,24 @@ export const syosetu = () => {
return mkRuleClass({
bookUrl: document.location.href,
bookname: (
document.querySelector(".novel_title") as HTMLElement
document.querySelector(".p-novel__title") as HTMLElement
).innerText.trim(),
author: (
document.querySelector(
".novel_writername > a, .novel_writername"
"body > div.l-container > main > article > div.p-novel__author > a"
) as HTMLAnchorElement
).innerText
.replace("作者:", "")
.trim(),
).innerText,
introDom: getIntroDom(),
introDomPatch: (dom) => dom,
coverUrl: null,
aList: getAList(),
sections: document.querySelectorAll("div.chapter_title"),
sections: document.querySelectorAll(".p-eplist__chapter-title"),
getSName: (dom) => (dom as HTMLElement).innerText.trim(),
getContent: (dom) => {
const content = document.createElement("div");
const novelP = dom.querySelector("#novel_p");
const novelHonbun = dom.querySelector("#novel_honbun");
const novelA = dom.querySelector("#novel_a");
const novelP = dom.querySelector(".p-novel__text--preface");
const novelHonbun = dom.querySelector(".p-novel__text:not(.p-novel__text--preface):not(.p-novel__text--afterword)");
const novelA = dom.querySelector(".p-novel__text--afterword");
if (novelP) {
content.appendChild(novelP);
const hr = dom.createElement("hr");
Expand Down
82 changes: 82 additions & 0 deletions src/rules/onePageWithMultiIndexPage/69shu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { rm, rm2 } from "../../lib/dom";
import { getHtmlDOM } from "../../lib/http";
import { mkRuleClass } from "./template";

export const c69shu = () =>
mkRuleClass({
bookUrl: document.location.href,
bookname: document.querySelector("h1")?.innerText ?? "",
author: document.querySelector<HTMLAnchorElement>(
".booknav2 > p:nth-child(3) > a"
)?.innerText ?? "",
introDom:
document.querySelector(
".lastcontent"
) as HTMLParagraphElement,
introDomPatch: (content) => content,
coverUrl: document.querySelector<HTMLImageElement>(".bookimg2 > img")?.src ?? null,
getIndexPages: async () => {
const indexPages: Document[] = [];
const menuUrl = (
document.querySelector('a.btn.more-btn[href^="https://69shuba.cx/book/"]') as HTMLAnchorElement
).href;
const doc = await getHtmlDOM(menuUrl, "GBK");
indexPages.push(doc);
return indexPages;
},
getAList: (doc) => Array.from(doc.querySelectorAll("#catalog ul a")).reverse() as unknown as NodeListOf<Element>,
getAName: (aElem) => (aElem as HTMLElement).innerText.trim(),
getContent: (doc) => doc.querySelector(".txtnav"),
contentPatch: (content) => {
rm(".hide720, .txtright, .bottom-ad", true, content);
rm2([/^谷[\u4e00-\u9fa5]{0,1}$/gm], content);

// Replace text nodes between <p> nodes with <p> nodes
const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT, null);
const nodesToReplace = [];

while (walker.nextNode()) {
const node = walker.currentNode;
if (
node.parentNode &&
node.parentNode.nodeName !== 'P' &&
node.textContent &&
node.textContent.trim() !== ''
) {
nodesToReplace.push(node);
}
}

nodesToReplace.forEach((node) => {
const p = document.createElement('p');
p.textContent = node.textContent;
if (node.parentNode) {
node.parentNode.replaceChild(p, node);
}
});

// Split <p> elements containing <br /> tags
const paragraphs = content.querySelectorAll('p');
const brRegex = /<br\s*\/?>/i;

paragraphs.forEach((p) => {
if (brRegex.test(p.innerHTML)) {
const parts = p.innerHTML.split(brRegex);
const fragment = document.createDocumentFragment();
parts.forEach((part) => {
const newP = document.createElement('p');
newP.innerHTML = part.trim();
if (newP.innerHTML !== '') {
fragment.appendChild(newP);
}
});
if (p.parentNode) {
p.parentNode.replaceChild(fragment, p);
}
}
});

return content;
},
language: "zh"
});
38 changes: 38 additions & 0 deletions src/rules/onePageWithMultiIndexPage/xbookcn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { getHtmlDOM } from "../../lib/http";
import { mkRuleClass } from "./template";

export const xbookcn = () =>
mkRuleClass({
bookUrl: document.location.href,
bookname: document.querySelector(".status-msg-body")?.textContent ?? "",
author: document.querySelector<HTMLAnchorElement>(
".entry-content > p:nth-child(1)"
)?.innerText.split(":")[1] ?? "",
introDom:
document.querySelector(
".entry-content"
) as HTMLParagraphElement,
introDomPatch: (content) => content,
coverUrl: null,
getIndexPages: async () => {
const bookUrl = document.location.origin + document.location.pathname;
const indexPages: Document[] = [];
let nextUrl = bookUrl;
do {
const doc = await getHtmlDOM(nextUrl, "UTF-8");
indexPages.push(doc);
nextUrl =
(
doc.querySelector(
"#Blog1_blog-pager-older-link"
) as HTMLAnchorElement
)?.href ?? null;
} while (nextUrl);
return indexPages;
},
getAList: (doc) => doc.querySelectorAll("h3 > a"),
getAName: (aElem) => (aElem as HTMLElement).innerText.trim(),
getContent: (doc) => doc.querySelector(".entry-content") as HTMLElement,
contentPatch: (content) => content,
language: "zh",
});
29 changes: 0 additions & 29 deletions src/rules/twoPage/69shu.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/save/epub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ export class EPUB extends Options {
[
`<?xml version="1.0" encoding="utf-8"?>`,
htmlText
.replaceAll("<p><br /></p>", "")
.replaceAll("<p><br/></p>", "")
.replaceAll("data-src-address", "src")
.replaceAll(/[\u{0000}-\u{001f}]/gu, "")
.replaceAll(/[\u{007f}-\u{009f}]/gu, "")
Expand Down
Loading