Skip to content

Instantly share code, notes, and snippets.

@JaosnHsieh
Forked from jeb5/Youtube Subs to OPML.js
Created August 15, 2021 08:16
Show Gist options
  • Save JaosnHsieh/8115bacd015bdc6d6410a145c5d7d3a4 to your computer and use it in GitHub Desktop.
Save JaosnHsieh/8115bacd015bdc6d6410a145c5d7d3a4 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"');
if (window.location.href == "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")
}
} else {
alert("Please run at \"https://www.youtube.com/feed/channels\"")
}

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 August 2021.

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