mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-16 07:44:44 +08:00
fix(route)(weibo): title, icon, regex (#9191)
Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
@@ -50,12 +50,12 @@ const weiboUtils = {
|
||||
let htmlNewLineUnreplaced = (status.longText && status.longText.longTextContent) || status.text || '';
|
||||
// 表情图标转换为文字
|
||||
if (!showEmojiInDescription) {
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class="url-icon"><img.*?alt="?(.*?)"? [\s\S]*?\/><\/span>/g, '$1');
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class=["']url-icon["']><img\s[^>]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1');
|
||||
}
|
||||
// 去掉外部链接的图标,保留 a 标签链接
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class=["|']url-icon["|']>.*?(<a.*?>).*?<\/span><span class="surl-text">(.*?)<\/span>/g, '$1$2</a>');
|
||||
// 去掉乱七八糟的图标
|
||||
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class=["|']url-icon["|']>(.*?)<\/span>/g, '');
|
||||
// 去掉外部链接的图标,保留 a 标签链接 // 不能去掉,否则像超话这样的有意义的图标也会被去掉
|
||||
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(<a\s[^>]*>)<span class=["']url-icon["']><img\s[^>]*><\/span>[^<>]*?<span class="surl-text">([^<>]*?)<\/span><\/a>/g, '$1$2</a>');
|
||||
// 去掉乱七八糟的图标 // 不能去掉,否则像超话这样的有意义的图标也会被去掉
|
||||
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class=["']url-icon["']>(<img\s[^>]*?>)<\/span>/g, '');
|
||||
// 去掉全文
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/全文<br>/g, '<br>');
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<a href="(.*?)">全文<\/a>/g, '');
|
||||
@@ -174,6 +174,8 @@ const weiboUtils = {
|
||||
}
|
||||
if (!status.retweeted_status || showRetweetTextInTitle) {
|
||||
title += htmlNewLineUnreplaced
|
||||
.replace(/<span class=["']url-icon["']><img\s[^>]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1') // 表情转换
|
||||
.replace(/<span class=["']url-icon["']>(<img\s[^>]*?>)<\/span>/g, '') // 去掉所有图标
|
||||
.replace(/<img[\s\S]*?>/g, '[图片]')
|
||||
.replace(/<.*?>/g, '')
|
||||
.replace('\n', '');
|
||||
@@ -181,6 +183,8 @@ const weiboUtils = {
|
||||
if (status.retweeted_status) {
|
||||
title += showEmojiForRetweet ? '🔁 ' : ' - 转发 ';
|
||||
title += retweeted
|
||||
.replace(/<span class=["']url-icon["']><img\s[^>]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1') // 表情转换
|
||||
.replace(/<span class=["']url-icon["']>(<img\s[^>]*?>)<\/span>/g, '') // 去掉所有图标
|
||||
.replace(/<img[\s\S]*?>/g, '[图片]')
|
||||
.replace(/<.*?>/g, '')
|
||||
.replace('\n', '');
|
||||
|
||||
Reference in New Issue
Block a user