aboutsummaryrefslogtreecommitdiff
path: root/content_scripts/cs.js
blob: 6b66d92c32c3cc2564ba347c7109869a731eeaef (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
var base_url = undefined

// Get the list of all feeds, combining bridged and native feeds
async function get_feed_urls() {
    let settings = await browser.storage.sync.get("rb");
    base_url = settings.rb;
    let all_feed_urls = []
    for (const bridge of bridges) {
        for (const host of bridge.hosts) {
            if (window.location.host.includes(host)) {
                result = await bridge.callback()
                all_feed_urls = all_feed_urls.concat(result)
                break
            }
        }
    }
    all_feed_urls = all_feed_urls.concat(find_feeds_in_page())
    return all_feed_urls
}

// Function to register a new bridge
let bridges = []
function register(hosts, callback) {
    bridges.push({hosts, callback})
}

browser.runtime.onMessage.addListener(function (msg, sender) {
    return Promise.resolve(get_feed_urls());
})