From 6d110e0dbc826742c9c04c09d630a32f45268971 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 29 Oct 2024 12:54:39 -0700 Subject: [PATCH] fix(route): mingpao mixed media (#17359) --- lib/routes/mingpao/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/routes/mingpao/index.ts b/lib/routes/mingpao/index.ts index 79131dd6d63566..b8f187884f809d 100644 --- a/lib/routes/mingpao/index.ts +++ b/lib/routes/mingpao/index.ts @@ -112,6 +112,12 @@ async function handler(ctx) { }); const $ = cheerio.load(response); + const topVideo = $('#topvideo').length + ? $('#topvideo iframe') + .toArray() + .map((e) => $(e).attr('href', $(e).attr('src'))) + .map((e) => fixFancybox(e, $)) + : []; const fancyboxImg = $('a.fancybox').length ? $('a.fancybox') : $('a.fancybox-buttons'); // remove unwanted elements @@ -125,7 +131,7 @@ async function handler(ctx) { item.category = item.categories; // fix fancybox image - let fancybox = fancyboxImg.toArray().map((e) => fixFancybox(e, $)); + let fancybox = [...topVideo, ...fancyboxImg.toArray().map((e) => fixFancybox(e, $))]; const script = $('script') .toArray() .find((e) => $(e).text()?.includes("$('#lower').prepend('"));