Skip to content

Instantly share code, notes, and snippets.

@alteredorange
Forked from jeb5/Youtube Subs to OPML.js
Created December 6, 2021 20:50
Show Gist options
  • Save alteredorange/4f51626d6f13a8e38dcd590b0e109b78 to your computer and use it in GitHub Desktop.
Save alteredorange/4f51626d6f13a8e38dcd590b0e109b78 to your computer and use it in GitHub Desktop.
Youtube Subscriptions to RSS feed
javascript:if("https://www.youtube.com/feed/channels"==window.location.href){let e=[...document.querySelectorAll("#main-link.channel-link")].map(e=>{const[,t,n]=e.href.match("/((?:user)|(?:channel))/(.*)$");return"https://www.youtube.com/feeds/videos.xml?"+("user"===t?"user=":"channel_id=")+n}).join("\n");e?navigator.clipboard.writeText(e).then(()=>alert("A list of channel RSS feeds has been copied to the clipboard. \nPaste these into rssmix.com to generate a single RSS feed, or opml-gen.ovh to generate an OPML file.")).catch(()=>{console.log(e),alert("A list of channel RSS feeds has logged to the console. (Unable to copy to clipboard) \nPaste these into rssmix.com to generate a single RSS feed, or opml-gen.ovh to generate an OPML file.")}):alert("Couldn't find any subscriptions")}else alert('Please run at "https://www.youtube.com/feed/channels"');
let rssText = [...document.querySelectorAll("#main-link.channel-link")].map((e) => {
const [, a, b] = e.href.match("/((?:user)|(?:channel))/(.*)$");
return "https://www.youtube.com/feeds/videos.xml?" + (a === "user" ? "user=" : "channel_id=") + b;
}).join("\n")
if (rssText) {
navigator.clipboard.writeText(rssText).then(
() => alert("A list of channel RSS feeds has been copied to the clipboard. \nPaste these into rssmix.com to generate a single RSS feed, or opml-gen.ovh to generate an OPML file.")
).catch(
() => {
console.log(rssText)
alert("A list of channel RSS feeds has logged to the console. (Unable to copy to clipboard) \nPaste these into rssmix.com to generate a single RSS feed, or opml-gen.ovh to generate an OPML file.")
}
)
} else {
alert("Couldn't find any subscriptions")
}

YouTube Subscriptions to RSS feed

To create an RSS feed of all your YouTube subscriptions:

  • Navigate to https://www.youtube.com/feed/channels, and scroll the page to make sure links to every channel are loaded.
  • Run the script or activate the bookmarklet to copy a list of channel RSS feeds to your clipboard.
  • Paste the copied list into rssmix.com to create a combined RSS feed of all channels, or into opml-gen.ovh to create an OPML file.

Works in Chrome, Firefox and Safari as of September 2021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment