mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 16:07:42 +08:00
fix(route)(weibo): misc icons break some readers (#9458)
Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
@@ -1197,7 +1197,8 @@ rule
|
||||
| displayVideo | 是否直接显示微博视频和 Live Photo,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | true |
|
||||
| displayArticle | 是否直接显示微博文章,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | false |
|
||||
| displayComments | 是否直接显示热门评论,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | false |
|
||||
| showEmojiInDescription | 是否展示正文中的 emoji 表情 | 0/1/true/false | true |
|
||||
| showEmojiInDescription | 是否展示正文中的微博表情,关闭则替换为 `[表情名]` | 0/1/true/false | true |
|
||||
| showLinkIconInDescription | 是否展示正文中的链接图标 | 0/1/true/false | true |
|
||||
|
||||
指定更多与默认值不同的参数选项可以改善 RSS 的可读性,如
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ const weiboUtils = {
|
||||
heightOfPics: fallback(params.heightOfPics, queryToInteger(routeParams.heightOfPics), -1),
|
||||
sizeOfAuthorAvatar: fallback(params.sizeOfAuthorAvatar, queryToInteger(routeParams.sizeOfAuthorAvatar), 48),
|
||||
showEmojiInDescription: fallback(params.showEmojiInDescription, queryToInteger(routeParams.showEmojiInDescription), true),
|
||||
showLinkIconInDescription: fallback(params.showLinkIconInDescription, queryToInteger(routeParams.showLinkIconInDescription), true),
|
||||
};
|
||||
|
||||
params = mergedParams;
|
||||
@@ -44,6 +45,7 @@ const weiboUtils = {
|
||||
heightOfPics,
|
||||
sizeOfAuthorAvatar,
|
||||
showEmojiInDescription,
|
||||
showLinkIconInDescription,
|
||||
} = params;
|
||||
|
||||
let retweeted = '';
|
||||
@@ -53,10 +55,14 @@ const weiboUtils = {
|
||||
if (!showEmojiInDescription) {
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class=["']url-icon["']><img\s[^>]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1');
|
||||
}
|
||||
// 去掉外部链接的图标,保留 a 标签链接 // 不能去掉,否则像超话这样的有意义的图标也会被去掉
|
||||
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(<a\s[^>]*>)<span class=["']url-icon["']><img\s[^>]*><\/span>[^<>]*?<span class="surl-text">([^<>]*?)<\/span><\/a>/g, '$1$2</a>');
|
||||
// 去掉乱七八糟的图标 // 不能去掉,否则像超话这样的有意义的图标也会被去掉
|
||||
// 去掉链接的图标,保留 a 标签链接
|
||||
if (!showLinkIconInDescription) {
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(<a\s[^>]*>)<span class=["']url-icon["']><img\s[^>]*><\/span>[^<>]*?<span class="surl-text">([^<>]*?)<\/span><\/a>/g, '$1$2</a>');
|
||||
}
|
||||
// 去掉乱七八糟的图标 // 不需要,上述的替换应该已经把所有的图标都替换掉了,且这条 regex 会破坏上述替换不发生时的输出
|
||||
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<span class=["']url-icon["']>(<img\s[^>]*?>)<\/span>/g, '');
|
||||
// 将行内图标的高度设置为一行,改善阅读体验。但有些阅读器删除了 style 属性,无法生效 // 不需要,微博已经作此设置
|
||||
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(?<=<span class=["']url-icon["']>)<img/g, '<img style="height: 1em"');
|
||||
// 去掉全文
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/全文<br>/g, '<br>');
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/<a href="(.*?)">全文<\/a>/g, '');
|
||||
|
||||
Reference in New Issue
Block a user