YouTube Playlist to RSS Bookmarklet
Drag this link to your bookmarks bar:
Or copy and paste this into the URL of a bookmark if you prefer:
javascript:(function() {function initMyBookmarklet() {myBookmarklet();}function myBookmarklet() {var myDialog = $(document.createElement('div'));myDialog.html('<input data-preserve-html-node="true" type="text" value="' + getlink() + '" id="unique-link-input" style="width: 95%">');myDialog.dialog({title: "Get YouTube Playlist RSS Link",classes: {'ui-dialog-buttonset': 'my-dialog-buttons'},resizable: false,height: "auto",width: 400,modal: true,open: function(event, ui) {$('.my-dialog-buttons :button')[0].focus();},buttons: {"Copy Link": function() {var copyText = document.getElementById("unique-link-input");copyText.select();copyText.setSelectionRange(0, 99999);document.execCommand("copy");myDialog.remove();},Cancel: function() {$(this).dialog("close");myDialog.remove();}}});}function getlink() {var result = "Did not work";var url = window.location.href;var baseUrl = "https://www.youtube.com/feeds/videos.xml?playlist_id=";/* get playlist id */if (url.indexOf("youtube.com") >= 0 && url.indexOf("list=") >= 0) {var playlistId = "";/* if multiple query parameters */if (url.indexOf("&", url.indexOf("list=")) >= 0) {playlistId = url.substring(url.indexOf("list=") + 5,url.indexOf("&", url.indexOf("list=") + 5));/* if only the list query paremter */} else if (url.indexOf("list=") >= 0) {playlistId = url.substring(url.indexOf("list=") + 5);}var shareUrl = baseUrl + playlistId;result = shareUrl;}return result;}var s1 = window.document.createElement('script');s1.setAttribute('src', 'https://code.jquery.com/jquery-3.4.1.min.js');window.document.body.appendChild(s1);var s2 = window.document.createElement('script');s2.setAttribute('src', 'https://code.jquery.com/ui/1.12.1/jquery-ui.min.js');window.document.body.appendChild(s2);s1.onload = s1.onreadystatechange = function() {if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {s2.onload = s2.onreadystatechange = function() {if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {initMyBookmarklet();}};}};var head = document.getElementsByTagName('HEAD')[0];var link = document.createElement('link');link.rel = 'stylesheet';link.type = 'text/css';link.href = 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css';head.appendChild(link);})();
Here is the javascript in the bookmarklet if you are interested:
function() {
function initMyBookmarklet() {
myBookmarklet();
}
function myBookmarklet() {
var myDialog = $(document.createElement('div'));
myDialog.html('<input data-preserve-html-node="true" type="text" value="' + getlink() + '" id="unique-link-input" style="width: 95%">');
myDialog.dialog({
title: "Get YouTube Playlist RSS Link",
classes: {
'ui-dialog-buttonset': 'my-dialog-buttons'
},
resizable: false,
height: "auto",
width: 400,
modal: true,
open: function(event, ui) {
$('.my-dialog-buttons :button')[0].focus();
},
buttons: {
"Copy Link": function() {
var copyText = document.getElementById("unique-link-input");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
myDialog.remove();
},
Cancel: function() {
$(this).dialog("close");
myDialog.remove();
}
}
});
}
function getlink() {
var result = "Did not work";
var url = window.location.href;
var baseUrl = "https://www.youtube.com/feeds/videos.xml?playlist_id=";
/* get playlist id */
if (url.indexOf("youtube.com") >= 0 && url.indexOf("list=") >= 0) {
var playlistId = "";
/* if multiple query parameters */
if (url.indexOf("&", url.indexOf("list=")) >= 0) {
playlistId = url.substring(
url.indexOf("list=") + 5,
url.indexOf("&", url.indexOf("list=") + 5)
);
/* if only the list query paremter */
} else if (url.indexOf("list=") >= 0) {
playlistId = url.substring(
url.indexOf("list=") + 5);
}
var shareUrl = baseUrl + playlistId;
result = shareUrl;
}
return result;
}
var s1 = window.document.createElement('script');
s1.setAttribute('src', 'https://code.jquery.com/jquery-3.4.1.min.js');
window.document.body.appendChild(s1);
var s2 = window.document.createElement('script');
s2.setAttribute('src', 'https://code.jquery.com/ui/1.12.1/jquery-ui.min.js');
window.document.body.appendChild(s2);
s1.onload = s1.onreadystatechange = function() {
if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
s2.onload = s2.onreadystatechange = function() {
if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
initMyBookmarklet();
}
};
}
};
var head = document.getElementsByTagName('HEAD')[0];
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css';
head.appendChild(link);
}