diff options
Diffstat (limited to 'cs.js')
-rw-r--r-- | cs.js | 80 |
1 files changed, 16 insertions, 64 deletions
@@ -41,84 +41,36 @@ function find_links_in_page() { return feeds } -function get_all_types(feed_url) { +function get_all_types(feed_url, note) { let feeds = []; formats.forEach(el => { - feeds.push({ - type: `rss-bridge: ${el}`, - url: feed_url + 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_insta(url) { - let insta_url = url + "?__a=1" - console.log("fetching") - let res = await fetch(insta_url); - let json = await res.json(); - let uid = json.graphql.user.id - let feed_url = `${base_url}/?action=display&bridge=Instagram&context=Username&u=${uid}&media_type=all&format=`; - return get_all_types(feed_url) -} - -function get_twitter(url) { - let pattern = /twitter.com\/(\w+).*/ - let match = url.match(pattern); - if (match) { - let twitter_handle = match[1] - let feed_url = `${base_url}/?action=display&bridge=Twitter&context=By+username&u=${twitter_handle}&format=` - return get_all_types(feed_url) - } - return [] -} - -async function get_youtube(url) { - // use link to channel if given a video url - let patternVideo = /youtube.com\/watch\?v=\w+/ - if (url.match(patternVideo)) { - url = document.querySelector("#channel-name a")["href"] - } - - let patternUser = /youtube.com\/user\/(\w+).*/ - let matchUser = url.match(patternUser) - - let patternChannel = /youtube.com\/channel\/(\w+).*/ - let matchChannel = url.match(patternChannel) - - let patternPlaylist = /youtube.com\/playlist\?list=(\w+)/ - let matchPlaylist = url.match(patternPlaylist) - - - if (matchUser) { - let user = matchUser[1]; - let feed_url = `${base_url}/?action=display&bridge=Youtube&context=By+username&u=${user}&duration_min=&duration_max=&format=` - return get_all_types(feed_url) - } else if (matchChannel) { - let channelId = matchChannel[1] - let feed_url = `${base_url}/?action=display&bridge=Youtube&context=By+channel+id&c=${channelId}&duration_min=&duration_max=&format=` - return get_all_types(feed_url) - } else if (matchPlaylist) { - let playlistId = matchPlaylist[1] - let native_url = `https://www.youtube.com/feeds/videos.xml?playlist_id=${playlistId}` - let feed_url = `${base_url}/?action=display&bridge=Youtube&context=By+playlist+Id&p=${playlistId}&duration_min=&duration_max=&format=` - let rb_feeds = get_all_types(feed_url) - return rb_feeds.concat([{ type: `native: Rss`, url: native_url }]) - } - return [] -} - 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 (url.includes("instagram")) { + if (host.includes("instagram")) { all_feed_urls = all_feed_urls.concat(await get_insta(url)) - } else if (url.includes("twitter")) { + } else if (host.includes("twitter")) { all_feed_urls = all_feed_urls.concat(get_twitter(url)) - } else if (url.includes("youtube")) { + } 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()) |