aboutsummaryrefslogtreecommitdiff
path: root/content_scripts/scraper.js
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts/scraper.js')
-rw-r--r--content_scripts/scraper.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/content_scripts/scraper.js b/content_scripts/scraper.js
new file mode 100644
index 0000000..51043c3
--- /dev/null
+++ b/content_scripts/scraper.js
@@ -0,0 +1,35 @@
+let types = {
+ 'application/rss+xml': "rss",
+ 'application/atom+xml': "atom",
+ 'application/rdf+xml': "rdf",
+ 'application/rss': "rss",
+ 'application/atom': "atom",
+ 'application/rdf': "rdf",
+ 'text/rss+xml': "rss",
+ 'text/atom+xml': "atom",
+ 'text/rdf+xml': "rdf",
+ 'text/rss': "rss",
+ 'text/atom': "atom",
+ 'text/rdf': "rdf"
+}
+
+// Scrape feed links from DOM
+function find_feeds_in_page() {
+ let links = document.querySelectorAll('link[type]');
+ let feeds = [];
+ for (let i = 0; i < links.length; i++) {
+ if (links[i].hasAttribute('type') && links[i].getAttribute('type') in types) {
+ let title = links[i].getAttribute('title')
+ let href = links[i].getAttribute('href')
+ let feed_url = new URL(href, window.location.href).href
+ let type = types[links[i].getAttribute('type')]
+ let feed = {
+ name: `native: ${title || type}`,
+ type: type,
+ url: feed_url,
+ };
+ feeds.push(feed);
+ }
+ }
+ return feeds
+}