From 8106effe7a209734f5620d686c19daefc8e45722 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 16 Dec 2023 22:35:05 +0800 Subject: [PATCH] fix: whole page rss check --- src/lib/rss.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/lib/rss.ts b/src/lib/rss.ts index 9af89e0..1865909 100644 --- a/src/lib/rss.ts +++ b/src/lib/rss.ts @@ -141,20 +141,19 @@ export async function getPageRSS(data: { } if (html) { - rssParser.parseString(html, (err, result) => { - if (!err) { - chrome.runtime.sendMessage(null, { - text: "addPageRSS", - feed: { - url: location.href, - title: result.title, - image - } - }) - } - }) + let feed + try { + feed = await rssParser.parseString(html) + } catch (error) {} + if (feed) { + pageRSS.push({ + url: location.href, + title: feed.title, + image + }); + unique.save(location.href) + } } } - unique.save(location.href) return pageRSS }