Skip to content

Commit

Permalink
fix(route): mingpao mixed media (#17359)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Oct 29, 2024
1 parent d6c106e commit 6d110e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/routes/mingpao/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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('"));
Expand Down

0 comments on commit 6d110e0

Please sign in to comment.