From 6504724e1b84cd6e7d9f85fd6e5e3d9423cdeb6a Mon Sep 17 00:00:00 2001 From: Rongrong <15956627+Rongronggg9@users.noreply.github.com> Date: Fri, 25 Feb 2022 07:27:59 +0800 Subject: [PATCH] fix(route)(weibo): title, icon, regex (#9191) Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com> --- lib/routes/weibo/utils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/routes/weibo/utils.js b/lib/routes/weibo/utils.js index 4e0eed4550..a72ba6bb20 100644 --- a/lib/routes/weibo/utils.js +++ b/lib/routes/weibo/utils.js @@ -50,12 +50,12 @@ const weiboUtils = { let htmlNewLineUnreplaced = (status.longText && status.longText.longTextContent) || status.text || ''; // 表情图标转换为文字 if (!showEmojiInDescription) { - htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<\/span>/g, '$1'); + htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1'); } - // 去掉外部链接的图标,保留 a 标签链接 - htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/.*?().*?<\/span>(.*?)<\/span>/g, '$1$2'); - // 去掉乱七八糟的图标 - // htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(.*?)<\/span>/g, ''); + // 去掉外部链接的图标,保留 a 标签链接 // 不能去掉,否则像超话这样的有意义的图标也会被去掉 + // htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(]*>)]*><\/span>[^<>]*?([^<>]*?)<\/span><\/a>/g, '$1$2'); + // 去掉乱七八糟的图标 // 不能去掉,否则像超话这样的有意义的图标也会被去掉 + // htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(]*?>)<\/span>/g, ''); // 去掉全文 htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/全文
/g, '
'); htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/全文<\/a>/g, ''); @@ -174,6 +174,8 @@ const weiboUtils = { } if (!status.retweeted_status || showRetweetTextInTitle) { title += htmlNewLineUnreplaced + .replace(/]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1') // 表情转换 + .replace(/(]*?>)<\/span>/g, '') // 去掉所有图标 .replace(//g, '[图片]') .replace(/<.*?>/g, '') .replace('\n', ''); @@ -181,6 +183,8 @@ const weiboUtils = { if (status.retweeted_status) { title += showEmojiForRetweet ? '🔁 ' : ' - 转发 '; title += retweeted + .replace(/]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1') // 表情转换 + .replace(/(]*?>)<\/span>/g, '') // 去掉所有图标 .replace(//g, '[图片]') .replace(/<.*?>/g, '') .replace('\n', '');