refactor: replace moyu.im to original sina link (#14874)

This commit is contained in:
Lemon
2024-03-21 01:04:17 +08:00
committed by GitHub
parent 40350abcbb
commit 8a04b52960
2 changed files with 10 additions and 1 deletions
+6
View File
@@ -20,6 +20,12 @@ async function handler() {
const response = await got(item.link);
const $ = load(response.data);
$('.wechat-hide').prev().nextAll().remove();
$('img').replaceWith((i, e) => {
const src = $(e).attr('src');
const alt = $(e).attr('alt');
const newSrc = src?.replace(/https?:\/\/(\w+)\.moyu\.im/, 'https://$1.sinaimg.cn');
return `<img src="${newSrc}" alt="${alt}">`;
});
const single = {
title: item.title,
description: $('.entry').html(),
+4 -1
View File
@@ -33,7 +33,10 @@ async function handler(ctx) {
item.find('.commenttext img, .tucao-report').remove();
item.find('.commenttext .view_img_link').each(function () {
$(this).replaceWith(`<img src="${$(this).attr('href')}">`);
const url = new URL($(this).attr('href'), rootUrl);
url.protocol = 'https:';
url.host = url.host.replace('moyu.im', 'sinaimg.cn');
$(this).replaceWith(`<img src="${url}">`);
});
const author = item.find('b').first().text();