-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (30 loc) · 922 Bytes
/
background.js
File metadata and controls
35 lines (30 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
chrome.alarms.create('fetchRSS', { periodInMinutes: 15 });
// Alarm listener
chrome.alarms.onAlarm.addListener((alarm) => {
if (alarm.name === 'fetchRSS') {
fetchRSSFeeds();
}
});
// Main function
async function fetchRSSFeeds() {
try {
const result = await chrome.storage.local.get(['rssFeeds']);
const feeds = result.rssFeeds || [];
if (feeds.length === 0) {
console.log('No RSS feeds saved.');
return;
}
for (const feedUrl of feeds) {
try {
const response = await fetch(feedUrl);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.text();
console.log(`Fetched feed from ${feedUrl}:`, data);
} catch (err) {
console.error(`Failed to fetch ${feedUrl}:`, err);
}
}
} catch (err) {
console.error('Error fetching RSS feeds:', err);
}
}