Last active
February 2, 2025 14:47
-
-
Save elevenpassin/584c5e54bca3a066f0d64468b1270477 to your computer and use it in GitHub Desktop.
Get YT Channel RSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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/* | |
// @match https://www.youtube.com/* | |
// @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