Skip to content

Commit

Permalink
Update QidianParser.js
Browse files Browse the repository at this point in the history
Swapped single quote to double quote

Optimize QidianParser.js for smaller files.

Cleanup output html data, removing unnecessary elements and frivolous metadata. Chapters are visibly the same, but content length reduced by around 50% on average.
  • Loading branch information
Kiradien committed Jun 29, 2024
1 parent 46cb9fa commit 83e64cc
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 83e64cc

Please sign in to comment.