-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent_script.js
More file actions
34 lines (31 loc) · 1.12 KB
/
content_script.js
File metadata and controls
34 lines (31 loc) · 1.12 KB
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
const isFirefox = typeof browser !== 'undefined';
const browserAPI = isFirefox ? browser : chrome;
function searchFeedsOnPage() {
url = window.location.href;
title = document.title || null;
try {
const feedLinks = Array.from(document.querySelectorAll('link[rel="alternate"]'));
const filteredLinks = feedLinks.filter(link =>
(link.type === 'application/rss+xml' || link.type === 'application/atom+xml')
);
if (filteredLinks.length > 0) {
const feeds = filteredLinks.map(link => ({
title: link.title || document.title,
href: link.href,
articles: [{
url: url,
title: title
}],
type: link.type,
show: true
}));
console.log('Found feeds:', feeds);
browserAPI.runtime.sendMessage({ action: 'recordFeeds', feeds });
} else {
console.log('No feeds found on this page.');
}
} catch (err) {
console.error('Error searching for feeds:', err);
}
}
searchFeedsOnPage();