From a1fbc4ac46e1c41d8c4522ae2b7af402ba0515f7 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 26 Jun 2021 14:58:14 -0500 Subject: Add support for multiple reader types --- index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 2138dd5..86220b9 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,17 @@ -var base_ttrss = undefined - -function subscribe_link(feed_url){ - return `${base_ttrss}/public.php?op=subscribe&feed_url=${encodeURIComponent(feed_url)}`; +var base_reader = undefined + +function subscribe_link(reader, feed_url){ + if(reader == "ttrss"){ + return `${base_reader}/public.php?op=subscribe&feed_url=${encodeURIComponent(feed_url)}`; + } else { + return `${base_reader}/bookmarklet?uri=${encodeURIComponent(feed_url)}`; + } } window.onload = async function () { - let settings = await browser.storage.sync.get(["tr", "rb"]); - base_ttrss = settings.tr; + let settings = await browser.storage.sync.get(["rb", "reader", "instance"]); + base_reader = settings.instance; let base_rb = settings.rb; let feeds = document.getElementById('feeds'); feeds.innerText = "Loading..." @@ -38,9 +42,9 @@ window.onload = async function () { let newDiv = document.createElement('div'); newDiv.append(newLink) - if(base_ttrss){ + if(base_reader){ let subLink = document.createElement('a'); - subLink["href"] = subscribe_link(item.url) + subLink["href"] = subscribe_link(settings.reader, item.url) subLink.innerText = "subscribe"; newDiv.append(subLink) } -- cgit v1.2.3