Skip to content

Commit

Permalink
Merge pull request #1363 from Kiradien/patch-3
Browse files Browse the repository at this point in the history
Optimize QidianParser.js for smaller files.
  • Loading branch information
dteviot authored Jun 30, 2024
2 parents 8def67b + 83e64cc commit 02e9050
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugin/js/parsers/QidianParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class QidianParser extends Parser{
preprocessRawDom(webPage) {
let content = this.findContent(webPage);
if (content !== null) {
content = this.cleanRawDom(content);
return;
}
let json = this.findChapterContentJson(webPage);
Expand All @@ -72,6 +73,14 @@ class QidianParser extends Parser{
}
}

cleanRawDom(content)
{
//Remove repeating & unused metadata from document. Approximately halves body length.
content.querySelectorAll("i.para-comment_num, i.para-comment").forEach(i => i.remove());
content.querySelectorAll("div.db").forEach(i => i.removeAttribute("data-ejs"));
return content;
}

findChapterContentJson(dom) {
const searchString = "var chapInfo=";
return [...dom.querySelectorAll("script")]
Expand Down

0 comments on commit 02e9050

Please sign in to comment.