aboutsummaryrefslogtreecommitdiff
path: root/content_scripts/scraper.js
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2022-12-30 13:58:20 -0600
committerMark Powers <mark@marks.kitchen>2022-12-30 13:58:20 -0600
commit3bdc11a9b2c78f2be8c11d28befce7328b6e5424 (patch)
tree98a88b435bf14f71a28537a0e5c8e052ab58a78c /content_scripts/scraper.js
parentb5c10718ddeaa8fcac368515ca150705b1a2c5ab (diff)
Improve RSS preview
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
+}