Forked from JamieMason/spotify-save-all-in-playlist.js
Created
April 30, 2014 08:51
-
-
Save ShaneHudson/113d61fa88c79b4d16a5 to your computer and use it in GitHub Desktop.
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
/* | |
* 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