From e2f6c7029046227c470072665373ac4dff0d0a3f Mon Sep 17 00:00:00 2001 From: Kenny Fong Date: Sat, 3 Aug 2024 03:23:11 +0800 Subject: [PATCH] fix(route/keylol): handle lazy load image (#16346) --- lib/routes/keylol/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/routes/keylol/index.ts b/lib/routes/keylol/index.ts index b149d146f..00ccfc552 100644 --- a/lib/routes/keylol/index.ts +++ b/lib/routes/keylol/index.ts @@ -186,6 +186,17 @@ async function handler(ctx) { function getDescription($) { const descriptionEl = $('td.t_f'); descriptionEl.find('div.rnd_ai_pr').remove(); // remove ad image + + // handle lazyload image + descriptionEl.find('img').each((_, img) => { + img = $(img); + if (img.attr('src')?.endsWith('none.gif') && img.attr('file')) { + img.attr('src', img.attr('file')); + img.removeAttr('file'); + img.removeAttr('zoomfile'); + } + }); + return descriptionEl.length > 0 ? descriptionEl.html() : $('div.alert_info').html(); }