diff --git a/rsspreview.js b/rsspreview.js index c92e3e9..67afec5 100644 --- a/rsspreview.js +++ b/rsspreview.js @@ -379,10 +379,16 @@ } function findYouTubeFeeds() { - let match = document.URL.match(/channel\/([a-zA-Z0-9_-]+)/); - if (match) { + // YouTube's canonical channel URLs look like /channel/AlphaNumericID + // It also supports named channels of the form /c/MyChannelName + // Match on both of these to autodetect channel feeds on either URL + let idPattern = /channel\/(?[a-zA-Z0-9_-]+)/; + let namePattern = /c\/[a-zA-Z0-9_-]+/; + let urlPattern = new RegExp(`${idPattern.source}|${namePattern.source}`); + if (document.URL.match(urlPattern)) { let feeds = {}; - let channelId = match[1]; + let canonicalUrl = document.querySelector("link[rel='canonical']").href; + let channelId = canonicalUrl.match(idPattern).groups.channelId; let url = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`; let title = document.title; feeds[url] = title;