aboutsummaryrefslogtreecommitdiff
path: root/index.js
blob: 9ba390e1c4b55e5444ade7b296efd86bd6c9be0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

var base_ttrss = undefined

function subscribe_link(feed_url){
    return `${base_ttrss}/public.php?op=subscribe&feed_url=${encodeURIComponent(feed_url)}`;
}

window.onload = async function () {
    let settings = await browser.storage.sync.get("tr");
    base_ttrss = settings.tr;
    let feeds = document.getElementById('feeds');
    feeds.innerText = "Loading..."
    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 newDiv = document.createElement('div');
                    newDiv.append(newLink)

                    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) {
                    let newP = document.createElement('p')
                    newP.innerText = "No feeds found"
                    feeds.append(newP)
                }
            });
    });
}