Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #1104
  • Loading branch information
dteviot committed Dec 9, 2023
1 parent bd79630 commit df54d79
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugin/js/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,10 @@ var util = (function () {
return (index === -1) ? null : uri.substring(index + 1);
}

var resolveLazyLoadedImages = function(content, imgCss) {
var resolveLazyLoadedImages = function(content, imgCss, attrName) {
attrName = attrName || "data-src";
for(let img of content.querySelectorAll(imgCss)) {
let dataSrc = img.getAttribute("data-src");
let dataSrc = img.getAttribute(attrName);
if (dataSrc !== null) {
img.src = dataSrc.trim();
}
Expand Down
39 changes: 39 additions & 0 deletions plugin/js/parsers/BoyloveParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use strict";

parserFactory.register("boylove.cc", () => new BoyloveParser());

class BoyloveParser extends Parser{
constructor() {
super();
}

async getChapterUrls(dom) {
return [...dom.querySelectorAll("ul#playlist__item_title_1_url li:not(.chapterOff) a")]
.map(a => util.hyperLinkToChapter(a));
}

findContent(dom) {
return dom.querySelector("section.reader-cartoon-chapter");
}

extractTitleImpl(dom) {
return dom.querySelector("div.stui-content div.title");
}

findChapterTitle(dom) {
return dom.querySelector("div.title");
}

findCoverImageUrl(dom) {
let div = dom.querySelector("div.stui-content__thumb [style*=background-image]");
return "https://boylove.cc" + util.extractUrlFromBackgroundImage(div);
}

preprocessRawDom(webPageDom) {
util.resolveLazyLoadedImages(webPageDom, "article img.lazy", "data-original");
}

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("p.desc")];
}
}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ <h3>Instructions</h3>
<script src="js/parsers/BookswithqianyaParser.js"></script>
<script src="js/parsers/Booktoki152Parser.js"></script>
<script src="js/parsers/BoxnovelOrgParser.js"></script>
<script src="js/parsers/BoyloveParser.js"></script>
<script src="js/parsers/Bqg225Parser.js"></script>
<script src="js/parsers/BnatranslationsParser.js"></script>
<script src="js/parsers/CangjiParser.js"></script>
Expand Down

0 comments on commit df54d79

Please sign in to comment.