mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 pref: 内容评估器优化
This commit is contained in:
parent
1c409cb369
commit
dfb893b31d
@ -4,38 +4,23 @@
|
||||
* @param link 链接
|
||||
*/
|
||||
export function contentEstimator(link) {
|
||||
const wxReg = /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/;
|
||||
const arxivReg = /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/;
|
||||
const chinaDailyReg = /(?:https?:\/\/)?(www\.)chinadaily.com.cn\/a\/[a-zA-Z0-9\d._?%&+\-=\/#]*/;
|
||||
const sspaiReg = /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/;
|
||||
const biliReadReg = /(?:https?:\/\/)?www\.bilibili\.com\/read\/[A-Za-z\d._?%&+\-=\/#]*/;
|
||||
if (wxReg.test(link)) {
|
||||
return {
|
||||
name: '微信文章',
|
||||
summaryLink: wxReg.exec(link)?.[0]
|
||||
};
|
||||
} else if (arxivReg.test(link)) {
|
||||
return {
|
||||
name: 'ArXiv论文',
|
||||
summaryLink: arxivReg.exec(link)?.[0]
|
||||
};
|
||||
} else if (sspaiReg.test(link)) {
|
||||
return {
|
||||
name: '少数派',
|
||||
summaryLink: sspaiReg.exec(link)?.[0]
|
||||
const patterns = [
|
||||
{ reg: /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/, name: '微信文章' },
|
||||
{ reg: /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/, name: 'ArXiv论文' },
|
||||
{ reg: /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/, name: '少数派' },
|
||||
{ reg: /(?:https?:\/\/)?www\.bilibili\.com\/read\/[A-Za-z\d._?%&+\-=\/#]*/, name: '哔哩哔哩专栏' },
|
||||
{ reg: /(?:https?:\/\/)?(www\.)chinadaily.com.cn\/a\/[a-zA-Z0-9\d._?%&+\-=\/#]*/, name: 'ChinaDaily' }
|
||||
];
|
||||
|
||||
for (const pattern of patterns) {
|
||||
if (pattern.reg.test(link)) {
|
||||
return {
|
||||
name: pattern.name,
|
||||
summaryLink: pattern.reg.exec(link)?.[0]
|
||||
};
|
||||
}
|
||||
} else if (biliReadReg.test(link)) {
|
||||
return {
|
||||
name: '哔哩哔哩专栏',
|
||||
summaryLink: biliReadReg.exec(link)?.[0]
|
||||
}
|
||||
} else if (chinaDailyReg.test(link)) {
|
||||
return {
|
||||
name: 'ChinaDaily',
|
||||
summaryLink: chinaDailyReg.exec(link)?.[0]
|
||||
}
|
||||
} else {
|
||||
logger.error("[R插件][总结模块] 内容评估出错...");
|
||||
throw Error("内容评估出错...");
|
||||
}
|
||||
|
||||
logger.error("[R插件][总结模块] 内容评估出错...");
|
||||
throw Error("内容评估出错...");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user