fix: replace weibo a href img (#14354)

This commit is contained in:
tmr 2024-02-01 10:20:39 +08:00 committed by GitHub
parent 57f439b799
commit 670f6f3ca7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -70,6 +70,7 @@ const process = (html, image_hotlink_template, multimedia_hotlink_template, wrap
if (image_hotlink_template) {
replaceUrls($, 'img, picture > source', image_hotlink_template);
replaceUrls($, 'video[poster]', image_hotlink_template, 'poster');
replaceUrls($, '*[data-rsshub-image="href"]', image_hotlink_template, 'href');
}
if (multimedia_hotlink_template) {
replaceUrls($, 'video, video > source, audio, audio > source', multimedia_hotlink_template);

View File

@ -82,7 +82,10 @@ const weiboUtils = {
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/<a href="(.*?)">全文<\/a>/g, '');
// 处理外部链接
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/https:\/\/weibo\.cn\/sinaurl\/.*?&u=(http.*?")/g, (match, p1) => decodeURIComponent(p1));
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/"https:\/\/weibo\.cn\/sinaurl.*?[&?]u=(http.*?)"/g, (match, p1) => `"${decodeURIComponent(p1)}"`);
// 处理图片的链接
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/<a\s+href="https?:\/\/.+\.(jpg|png|gif)"/g, (match) => `${match} data-rsshub-image="href"`);
let html = htmlNewLineUnreplaced.replaceAll('\n', '<br>');