From 2be03e1935e0019fa5c03893dc12acf6ee546222 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sun, 22 Nov 2020 22:29:17 -0600 Subject: Add options and youtube feed support --- index.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 8a6f81b..9ba390e 100644 --- a/index.js +++ b/index.js @@ -1,28 +1,36 @@ -let base_ttrss = "https://fr.marks.kitchen/public.php?op=subscribe&feed_url=" + +var base_ttrss = undefined + function subscribe_link(feed_url){ - return `${base_ttrss}${encodeURIComponent(feed_url)}`; + return `${base_ttrss}/public.php?op=subscribe&feed_url=${encodeURIComponent(feed_url)}`; } -window.onload = function () { +window.onload = async function () { + let settings = await browser.storage.sync.get("tr"); + base_ttrss = settings.tr; let feeds = document.getElementById('feeds'); feeds.innerText = "Loading..." - console.log(feeds.innerHTML.toString()) browser.tabs.query({ active: true, currentWindow: true }, function (tabs) { browser.tabs.sendMessage(tabs[0].id, {}).then( function (feed_urls) { feeds.innerText = "" + feed_urls.forEach(item => { let newLink = document.createElement('a'); newLink["href"] = item.url newLink.innerText = item.type; - let subLink = document.createElement('a'); - subLink["href"] = subscribe_link(item.url) - subLink.innerText = "subscribe"; let newDiv = document.createElement('div'); newDiv.append(newLink) - newDiv.append(subLink) + + if(base_ttrss){ + let subLink = document.createElement('a'); + subLink["href"] = subscribe_link(item.url) + subLink.innerText = "subscribe"; + newDiv.append(subLink) + } + feeds.append(newDiv) }) if(feed_urls.length == 0) { -- cgit v1.2.3