diff options
author | Mark Powers <markpowers@uchicago.edu> | 2021-06-26 14:58:14 -0500 |
---|---|---|
committer | Mark Powers <markpowers@uchicago.edu> | 2021-06-26 14:58:14 -0500 |
commit | a1fbc4ac46e1c41d8c4522ae2b7af402ba0515f7 (patch) | |
tree | 728d76a11ed4d5e8321804aa177356f5d57e84d6 | |
parent | c5cf1359762274a17fb139944405c02618996700 (diff) |
Add support for multiple reader types
-rw-r--r-- | index.js | 20 | ||||
-rw-r--r-- | manifest.json | 2 | ||||
-rw-r--r-- | options.html | 15 | ||||
-rw-r--r-- | options.js | 9 |
4 files changed, 31 insertions, 15 deletions
@@ -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) } diff --git a/manifest.json b/manifest.json index 7ed3af5..9cb0321 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "description": "Finds feeds or generates RSS-Bridge URLs for the current page. Optional integration with tt-rss.", "manifest_version": 2, "name": "RSS-Bridge helper", - "version": "1.0", + "version": "1.1", "content_scripts": [ { "matches": [ diff --git a/options.html b/options.html index b248905..5677612 100644 --- a/options.html +++ b/options.html @@ -14,8 +14,17 @@ <td><input type="text" id="rb"></td> </tr> <tr> - <td><label for="tr">tt-rss instance</label></td> - <td><input type="text" id="tr"></td> + <td><label for="reader">reader type:</label></td> + <td> + <select name="reader" id="reader"> + <option value="ttrss">TT-RSS</option> + <option value="miniflux">Miniflux</option> + </select> + </td> + </tr> + <tr> + <td><label for="instance">instance URL:</label></td> + <td><input type="text" id="instance"></td> </tr> <tr> <td> @@ -27,4 +36,4 @@ <script src="options.js"></script> </body> -</html>
\ No newline at end of file +</html> @@ -2,19 +2,22 @@ function saveOptions(e) { e.preventDefault(); browser.storage.sync.set({ rb: document.querySelector("#rb").value, - tr: document.querySelector("#tr").value + reader: document.querySelector("#reader").value, + instance: document.querySelector("#instance").value }); } function restoreOptions() { function setCurrentChoice(result) { document.querySelector("#rb").value = result.rb || ""; - document.querySelector("#tr").value = result.tr || ""; + document.querySelector("#reader").value = result.reader|| ""; + document.querySelector("#instance").value = result.instance || ""; } function onError(error) { console.log(`Error: ${error}`); } - let getting = browser.storage.sync.get(["rb", "tr"]); + let getting = browser.storage.sync.get(["rb", "instance", "reader"]); getting.then(setCurrentChoice, onError); } document.addEventListener("DOMContentLoaded", restoreOptions); document.querySelector("form").addEventListener("submit", saveOptions); + |