fix(source): bypass image CDN in Linovelib (#716)
* fix(source): bypass image CDN in Linovelib * fix(source): also check for src attribute in img in Linovelib
This commit is contained in:
@@ -140,9 +140,19 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
|
||||
// Load lazyloaded images
|
||||
loadedCheerio('#acontent img.imagecontent').each(function () {
|
||||
const imgSrc = loadedCheerio(this).attr('data-src');
|
||||
// Sometimes images are either in data-src or src
|
||||
const imgSrc =
|
||||
loadedCheerio(this).attr('data-src') || loadedCheerio(this).attr('src');
|
||||
if (imgSrc) {
|
||||
loadedCheerio(this).attr('src', imgSrc);
|
||||
// The original CDN URL is locked behind a CF-like challenge, switch the URL to bypass that
|
||||
// There are no react-native-url-polyfill lib, can't use URL API
|
||||
const regex = /\/\/.+\.com\//;
|
||||
const imgUrl = imgSrc.replace(regex, '//img.linovelib.com/');
|
||||
// Clean up img element
|
||||
loadedCheerio(this)
|
||||
.attr('src', imgUrl)
|
||||
.removeAttr('data-src')
|
||||
.removeClass('lazyload');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -257,7 +267,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
};
|
||||
|
||||
Object.entries(mapping_dict).forEach(([key, value]) => {
|
||||
chapterText.replaceAll(key, value);
|
||||
chapterText = chapterText.replaceAll(key, value);
|
||||
});
|
||||
|
||||
const chapterName =
|
||||
|
||||
Reference in New Issue
Block a user