diff --git a/docs/social-media.md b/docs/social-media.md
index c1bbd18855..67569f3467 100644
--- a/docs/social-media.md
+++ b/docs/social-media.md
@@ -1522,6 +1522,7 @@ rule
| displayComments | 是否直接显示热门评论,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | false |
| showEmojiInDescription | 是否展示正文中的微博表情,关闭则替换为 `[表情名]` | 0/1/true/false | true |
| showLinkIconInDescription | 是否展示正文中的链接图标 | 0/1/true/false | true |
+| preferMobileLink | 是否使用移动版链接(默认使用 PC 版) | 0/1/true/false | false |
指定更多与默认值不同的参数选项可以改善 RSS 的可读性,如
@@ -1541,7 +1542,7 @@ rule
### 关键词
-
+
### 热搜榜
@@ -1549,7 +1550,7 @@ rule
### 超话
-
+
| type | 备注 |
| --------- | ---------------- |
@@ -1576,7 +1577,7 @@ rule
### 自定义分组
-
+
::: warning 注意
diff --git a/lib/v2/weibo/group.js b/lib/v2/weibo/group.js
index b5df42c69a..cd184e02cc 100644
--- a/lib/v2/weibo/group.js
+++ b/lib/v2/weibo/group.js
@@ -54,11 +54,8 @@ module.exports = async (ctx) => {
}
}
- const link = `https://m.weibo.cn/status/${item.bid}`;
const formatExtended = weiboUtils.formatExtended(ctx, item);
let description = formatExtended.description;
- const title = formatExtended.title;
- const pubDate = item.created_at;
if (displayVideo === '1') {
if (item.retweeted_status) {
@@ -81,11 +78,8 @@ module.exports = async (ctx) => {
}
return {
- title,
+ ...formatExtended,
description,
- link,
- pubDate,
- author: item.user.screen_name,
};
})
);
diff --git a/lib/v2/weibo/keyword.js b/lib/v2/weibo/keyword.js
index 2e8209c58b..5ac90ce552 100644
--- a/lib/v2/weibo/keyword.js
+++ b/lib/v2/weibo/keyword.js
@@ -37,19 +37,10 @@ module.exports = async (ctx) => {
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
}
- const formatExtended = weiboUtils.formatExtended(ctx, item.mblog, {
+ return weiboUtils.formatExtended(ctx, item.mblog, undefined, {
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
showAuthorInDesc: fallback(undefined, queryToBoolean(routeParams.showAuthorInDesc), true),
});
- const title = formatExtended.title;
- const description = formatExtended.description;
- return {
- title,
- description,
- pubDate: item.mblog.created_at,
- author: item.mblog.user.screen_name,
- link: `https://weibo.com/${item.mblog.user.id}/${item.mblog.bid}`,
- };
}),
});
};
diff --git a/lib/v2/weibo/maintainer.js b/lib/v2/weibo/maintainer.js
index afbc9f9a98..f6091f396c 100644
--- a/lib/v2/weibo/maintainer.js
+++ b/lib/v2/weibo/maintainer.js
@@ -1,9 +1,9 @@
module.exports = {
- '/group/:gid/:gname?/:routeParams?': ['monologconnor'],
- '/keyword/:keyword/:routeParams?': ['DIYgod'],
+ '/group/:gid/:gname?/:routeParams?': ['monologconnor', 'Rongronggg9'],
+ '/keyword/:keyword/:routeParams?': ['DIYgod', 'Rongronggg9'],
'/oasis/user/:userid': ['kt286'],
'/search/hot': ['xyqfer'],
- '/super_index/:id/:type?/:routeParams?': ['zengxs'],
- '/timeline/:uid/:feature?/:routeParams?': ['zytomorrow', 'DIYgod ', 'Rongronggg9'],
+ '/super_index/:id/:type?/:routeParams?': ['zengxs', 'Rongronggg9'],
+ '/timeline/:uid/:feature?/:routeParams?': ['zytomorrow', 'DIYgod', 'Rongronggg9'],
'/user/:uid/:routeParams?': ['DIYgod', 'iplusx', 'Rongronggg9'],
};
diff --git a/lib/v2/weibo/super_index.js b/lib/v2/weibo/super_index.js
index 4cf15c14cd..98cb459770 100644
--- a/lib/v2/weibo/super_index.js
+++ b/lib/v2/weibo/super_index.js
@@ -1,6 +1,5 @@
const got = require('@/utils/got');
const weiboUtils = require('./utils');
-const timezone = require('@/utils/timezone');
const queryString = require('query-string');
const config = require('@/config').value;
@@ -40,15 +39,7 @@ module.exports = async (ctx) => {
if (mblogCard.card_type === '9' && 'mblog' in mblogCard) {
const mblog = mblogCard.mblog;
const formatExtended = weiboUtils.formatExtended(ctx, mblog);
- const title = formatExtended.title;
- const desc = formatExtended.description;
- resultItems.push({
- title,
- description: desc,
- author: mblog.user.screen_name,
- link: `https://weibo.com/${mblog.user.id}/${mblog.bid}`,
- pubDate: timezone(mblog.created_at, +8),
- });
+ resultItems.push(formatExtended);
}
}
}
diff --git a/lib/v2/weibo/timeline.js b/lib/v2/weibo/timeline.js
index 06bc749d7a..c77806fccf 100644
--- a/lib/v2/weibo/timeline.js
+++ b/lib/v2/weibo/timeline.js
@@ -83,11 +83,11 @@ module.exports = async (ctx) => {
}
}
- const link = `https://weibo.com/${uid}/${item.id}`;
+ const guid = `https://weibo.com/${uid}/${item.id}`;
+ // not using formatExtended.guid in order not to introduce breaking change
- const formatExtended = weiboUtils.formatExtended(ctx, item);
+ const formatExtended = weiboUtils.formatExtended(ctx, item, uid);
let description = formatExtended.description;
- const title = formatExtended.title;
const pubDate = isDataOK ? parseDate(data.created_at) : parseDate(item.created_at);
// 视频的处理
@@ -116,9 +116,9 @@ module.exports = async (ctx) => {
}
return {
- title,
+ ...formatExtended,
+ guid,
description,
- link,
pubDate,
author: item.user.screen_name,
};
diff --git a/lib/v2/weibo/user.js b/lib/v2/weibo/user.js
index dead03f488..af7abf4e86 100644
--- a/lib/v2/weibo/user.js
+++ b/lib/v2/weibo/user.js
@@ -94,11 +94,8 @@ module.exports = async (ctx) => {
}
}
- const link = `https://m.weibo.cn/status/${item.mblog.bid}`;
- const formatExtended = weiboUtils.formatExtended(ctx, item.mblog);
+ const formatExtended = weiboUtils.formatExtended(ctx, item.mblog, uid);
let description = formatExtended.description;
- const title = formatExtended.title;
- const pubDate = item.mblog.created_at;
// 视频的处理
if (displayVideo === '1') {
@@ -126,11 +123,8 @@ module.exports = async (ctx) => {
}
return {
- title,
+ ...formatExtended,
description,
- link,
- pubDate,
- author: item.mblog.user.screen_name,
isPinned: item.profile_type_id?.startsWith('proweibotop'),
};
})
diff --git a/lib/v2/weibo/utils.js b/lib/v2/weibo/utils.js
index bb3b751a02..0087792f42 100644
--- a/lib/v2/weibo/utils.js
+++ b/lib/v2/weibo/utils.js
@@ -14,7 +14,9 @@ const weiboUtils = {
.replace(/<[^<]*>/g, '')
.replace(/\n/g, ' ')
.trim(),
- formatExtended: (ctx, status, params = {}, picsPrefixes = []) => {
+ formatExtended: (ctx, status, uid = undefined, params = {}, picsPrefixes = []) => {
+ // `uid = undefined` to explicitly mark it as optional, avoiding IDEs prompting warnings
+
// undefined and strings like "1" is also safely parsed, so no if branch is needed
const routeParams = querystring.parse(ctx.params.routeParams);
@@ -35,6 +37,7 @@ const weiboUtils = {
sizeOfAuthorAvatar: fallback(params.sizeOfAuthorAvatar, queryToInteger(routeParams.sizeOfAuthorAvatar), 48),
showEmojiInDescription: fallback(params.showEmojiInDescription, queryToInteger(routeParams.showEmojiInDescription), true),
showLinkIconInDescription: fallback(params.showLinkIconInDescription, queryToInteger(routeParams.showLinkIconInDescription), true),
+ preferMobileLink: fallback(params.preferMobileLink, queryToBoolean(routeParams.preferMobileLink), false),
};
params = mergedParams;
@@ -56,6 +59,7 @@ const weiboUtils = {
sizeOfAuthorAvatar,
showEmojiInDescription,
showLinkIconInDescription,
+ preferMobileLink,
} = params;
let retweeted = '';
@@ -191,7 +195,7 @@ const weiboUtils = {
retweetedParams.showAuthorInDesc = true;
retweetedParams.showAuthorAvatarInDesc = false;
retweetedParams.showAtBeforeAuthor = true;
- retweeted += weiboUtils.formatExtended(ctx, status.retweeted_status, retweetedParams, picsPrefixes).description;
+ retweeted += weiboUtils.formatExtended(ctx, status.retweeted_status, undefined, retweetedParams, picsPrefixes).description;
html += retweeted;
@@ -231,7 +235,15 @@ const weiboUtils = {
title += ' [视频]';
}
- return { description: html, title };
+ uid = uid || status.user?.id;
+ const bid = status.bid || status.id;
+ const guid = uid ? `https://weibo.com/${uid}/${bid}` : `https://m.weibo.cn/status/${bid}`;
+ const link = preferMobileLink ? `https://m.weibo.cn/status/${bid}` : guid;
+
+ const author = status.user?.screen_name;
+ const pubDate = status.created_at;
+
+ return { description: html, title, link, guid, author, pubDate };
},
getShowData: async (uid, bid) => {
const link = `https://m.weibo.cn/statuses/show?id=${bid}`;