Skip to content

Instantly share code, notes, and snippets.

@elevenpassin
Created December 16, 2021 20:28
Show Gist options
  • Save elevenpassin/584c5e54bca3a066f0d64468b1270477 to your computer and use it in GitHub Desktop.
Save elevenpassin/584c5e54bca3a066f0d64468b1270477 to your computer and use it in GitHub Desktop.
Get YT Channel RSS

Get YT Channel RSS | Violentmonkey Script

// ==UserScript==
// @name Get Channel RSS - youtube.com
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/c/*
// @match https://www.youtube.com/channel/*
// @match https://www.youtube.com/user/*
// @grant none
// @version 1.0
// @author -
// @description 28/09/2021, 14:10:10
// ==/UserScript==
const findChannelRSSFeed = () => {
for (var arrScripts = document.getElementsByTagName('script'), i = 0; i < arrScripts.length; i++) {
if (arrScripts[i].textContent.indexOf('externalId') != -1) {
var channelId = arrScripts[i].textContent.match(/\"externalId\"\s*\:\s*\"(.*?)\"/)[1];
var channelRss = 'https://www.youtube.com/feeds/videos.xml?channel_id=' + channelId;
var channelTitle = document.title.match(/\(?\d*\)?\s?(.*?)\s\-\sYouTube/)[1];
console.log('The rss feed of the channel \'' + channelTitle + '\' is:\n' + channelRss);
return channelRss;
}
}
}
const copyChannelRSSToClipboard = () => {
const rssFeed = findChannelRSSFeed();
navigator.clipboard.writeText(rssFeed).then(function() {
/* clipboard successfully set */
alert("Copied successfully")
}, function() {
alert("Something went wrong!")
});
}
const copyRSSBtn = document.createElement('button');
copyRSSBtn.textContent = 'Copy RSS Feed';
copyRSSBtn.style.position = 'fixed';
copyRSSBtn.style.bottom = 0;
copyRSSBtn.style.right = 0;
copyRSSBtn.onclick = copyChannelRSSToClipboard;
document.body.appendChild(copyRSSBtn);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment