var base_url = undefined let formats = ["Atom", "Mrss", "Html"] let types = { 'application/rss+xml': "rss", 'application/atom+xml': "atom", 'application/rdf+xml': "rdf", 'application/rss': "rss", 'application/atom': "atom", 'application/rdf': "rdf", 'text/rss+xml': "rss", 'text/atom+xml': "atom", 'text/rdf+xml': "rdf", 'text/rss': "rss", 'text/atom': "atom", 'text/rdf': "rdf" } function normalize_feed_url(feed_url) { if (feed_url.startsWith('/')) { let url = window.location.href feed_url = url.split('/')[0] + '//' + url.split('/')[2] + feed_url; } return feed_url } function find_links_in_page() { let links = document.querySelectorAll('link[type]'); let feeds = []; for (let i = 0; i < links.length; i++) { if (links[i].hasAttribute('type') && links[i].getAttribute('type') in types) { let title = links[i].getAttribute('title') let feed_url = normalize_feed_url(links[i].getAttribute('href')); let type = types[links[i].getAttribute('type')] let feed = { type: `native: ${title || type}`, url: feed_url, }; feeds.push(feed); } } return feeds } function get_all_types(feed_url, note) { let feeds = []; formats.forEach(el => { if(note){ feeds.push({ type: `rss-bridge (${note}): ${el}`, url: feed_url + el }); } else { feeds.push({ type: `rss-bridge: ${el}`, url: feed_url + el }); } }) return feeds; } async function get_feed_urls() { let settings = await browser.storage.sync.get("rb"); base_url = settings.rb; let all_feed_urls = [] let url = window.location.href; let host = window.location.host; //url = url.toLowerCase() if (host.includes("instagram")) { all_feed_urls = all_feed_urls.concat(await get_insta(url)) } else if (host.includes("twitter")) { all_feed_urls = all_feed_urls.concat(get_twitter(url)) } else if (host.includes("youtube")) { all_feed_urls = all_feed_urls.concat(await get_youtube(url)) } all_feed_urls = all_feed_urls.concat(find_links_in_page()) return all_feed_urls } browser.runtime.onMessage.addListener(function (msg, sender) { return Promise.resolve(get_feed_urls()); })