Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ShaneHudson/113d61fa88c79b4d16a5 to your computer and use it in GitHub Desktop.
Save ShaneHudson/113d61fa88c79b4d16a5 to your computer and use it in GitHub Desktop.
/*
* This Script adds every song in the playlist you're currently
* viewing at https://play.spotify.com to "Your Music".
*
* Open your browser console and paste this script to run it.
*/
(function() {
// Get the ID of the playlist you're currently viewing at https://play.spotify.com.
var playlistFrameId = document.querySelector('iframe[id^=collection]').getAttribute('id');
// Get the child window that playlist is being displayed in.
var playlistFrame = window[playlistFrameId].contentWindow;
// Get all the + or √ buttons
var saveButtons = playlistFrame.document.querySelectorAll('[data-ta-id="track-add-button"]');
// filter out the √ buttons (delete the "!" to filter out the + buttons instead).
[].slice.call(saveButtons).filter(function(button) {
return !button.parentNode.parentNode.matches('.added');
})
// Loop over the remaining buttons.
.forEach(function(button) {
// and click them.
button.click();
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment