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

feat: 🎸 support 69yuedu #714

Merged
merged 1 commit into from
Dec 24, 2024
Merged
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ EPUB 文件请使用相应阅读器阅读。
| [缤纷幻想](https://colorful-fantasybooks.com/) | ✅ | ❎ | |
| [弟子小说网](https://www.dizishu.cc/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 All @@ -186,6 +186,7 @@ EPUB 文件请使用相应阅读器阅读。
| [新笔趣阁](http://www.boqugew.com/) | ✅ | ❎ | |
| [全本同人小说](https://www.qbtr.cc/) | ✅ | ❎ | |
| [鬼大爷网](https://b.guidaye.com/) | ✅ | ❎ | |
| [69阅读](https://www.69yuedu.net/) | ✅ | ❎ | |

</details>

Expand Down
3 changes: 2 additions & 1 deletion src/header.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@
"*://www.fxshu.top/*/*.html",
"*://xr.unionread.net/bookdetail/*",
"*://www.qu-la.com/booktxt/*/",
"*://www.bilibili.com/read/readlist/*"
"*://www.bilibili.com/read/readlist/*",
"*://www.69yuedu.net/article/*.html"
],
"exclude": [
"*://www.jjwxc.net/onebook.php?novelid=*&chapterid=*",
Expand Down
5 changes: 5 additions & 0 deletions src/router/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ export async function getRule(): Promise<BaseRuleClass> {
ruleClass = xbookcn();
break;
}
case "www.69yuedu.net": {
const { c69yuedu } = await import("../rules/onePageWithMultiIndexPage/69yuedu");
ruleClass = c69yuedu();
break;
}
/* twoPage End */

/** mbtxt **/
Expand Down
84 changes: 84 additions & 0 deletions src/rules/onePageWithMultiIndexPage/69yuedu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { rm, rm2 } from "../../lib/dom";

Check warning on line 1 in src/rules/onePageWithMultiIndexPage/69yuedu.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'rm2' is defined but never used
import { getHtmlDOM } from "../../lib/http";
import { mkRuleClass } from "./template";

export const c69yuedu = () =>
mkRuleClass({
bookUrl: document.location.href,
bookname: document.querySelector("h1")?.innerText ?? "",
author: document.querySelector<HTMLAnchorElement>(
".booknav2 > p:nth-child(2) > a"
)?.innerText ?? "",
introDom:
document.querySelector(
".navtxt"
) as HTMLParagraphElement,
introDomPatch: (content) => content,
coverUrl: document.querySelector<HTMLImageElement>(".bookimg2 > img")?.src ?? null,
getIndexPages: async () => {
const indexPages: Document[] = [];
const menuUrl = (
document.querySelector('.addbtn a.btn[href^="/chapters/"]') as HTMLAnchorElement
).href;
const doc = await getHtmlDOM(menuUrl, "GBK");
indexPages.push(doc);
return indexPages;
},
getAList: (doc) => Array.from(doc.querySelectorAll("#chapters ul a")) as unknown as NodeListOf<Element>,
getAName: (aElem) => (aElem as HTMLElement).innerText.trim(),
getContent: (doc) => doc.querySelector(".content"),
contentPatch: (content) => {
rm(".txtright, .bottom-ad", true, 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",
concurrencyLimit: 1,
sleepTime: 500,
maxSleepTime: 1500
});
Loading