fix extraction of images to not get true as altags or empty src images

This commit is contained in:
2026-04-08 22:18:21 +02:00
parent 8e7e895e74
commit 4880b34792
+12 -4
View File
@@ -472,10 +472,18 @@ function contentDispatch(funcName, args) {
})); }));
} }
function extractImages() { function extractImages() {
return Array.from(document.querySelectorAll("img")).map(img => ({ return Array.from(document.querySelectorAll("img")).map(img => {
alt: img.alt, const src =
src: img.src, img.src ||
})); img.getAttribute("data-src") ||
img.getAttribute("data-lazy-src") ||
img.getAttribute("data-original") ||
(img.srcset ? img.srcset.split(",")[0].trim().split(" ")[0] : "") ||
"";
const FAKE_ALT = new Set(["true", "false", "null", "undefined", "image", "img"]);
const alt = img.alt && !FAKE_ALT.has(img.alt.trim().toLowerCase()) ? img.alt.trim() : "";
return { alt, src };
}).filter(img => img.src !== "");
} }
function extractText() { function extractText() {
return document.body.innerText; return document.body.innerText;