mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
fix: 修改画廊页面的图像加载逻辑以正确提取缩略图和名称
This commit is contained in:
@@ -177,10 +177,9 @@ class GalleryPage {
|
|||||||
}
|
}
|
||||||
async #get_imagelist() {
|
async #get_imagelist() {
|
||||||
function load_image(doc: Element): Page[] {
|
function load_image(doc: Element): Page[] {
|
||||||
const eles = doc.querySelectorAll("#gdt > div[class^=gdt]");
|
const eles = doc.querySelectorAll("#gdt > a");
|
||||||
return map(eles, (e) => {
|
return map(eles, (e) => {
|
||||||
const b = e as Element;
|
const a = e as Element;
|
||||||
const a = b.querySelector("a");
|
|
||||||
if (!a) throw Error("Link not found.");
|
if (!a) throw Error("Link not found.");
|
||||||
const href = a.getAttribute("href");
|
const href = a.getAttribute("href");
|
||||||
if (!href) throw Error("Link not found.");
|
if (!href) throw Error("Link not found.");
|
||||||
@@ -190,14 +189,14 @@ class GalleryPage {
|
|||||||
}
|
}
|
||||||
const token = u.token;
|
const token = u.token;
|
||||||
const index = u.index;
|
const index = u.index;
|
||||||
const img = b.querySelector("img");
|
const img = a.querySelector("div");
|
||||||
if (!img) throw Error("Image not found.");
|
if (!img) throw Error("Image not found.");
|
||||||
const thumbnail = img.getAttribute("src");
|
const thumbnail = img.getAttribute("style")?.match(/url\((.*)\)/i);
|
||||||
if (!thumbnail) throw Error("Image source not found");
|
if (!thumbnail) throw Error("Image source not found");
|
||||||
const name = img.getAttribute("title")?.match(/page \d+: (.*)/i)
|
const name = img.getAttribute("title")?.match(/page \d+: (.*)/i)
|
||||||
?.at(1);
|
?.at(1);
|
||||||
if (!name) throw Error("name not found");
|
if (!name) throw Error("name not found");
|
||||||
return { name, token, thumbnail, index };
|
return { name, token, thumbnail: thumbnail[1], index };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let b = load_image(this.doc);
|
let b = load_image(this.doc);
|
||||||
|
|||||||
Reference in New Issue
Block a user