Skip to content

Instantly share code, notes, and snippets.

@CodeDraken
Last active March 8, 2017 20:40
Show Gist options
  • Save CodeDraken/d55faa44000deae2458ee890b81c8880 to your computer and use it in GitHub Desktop.
Save CodeDraken/d55faa44000deae2458ee890b81c8880 to your computer and use it in GitHub Desktop.
Spotify Add / Favorite Script - use it in a playlist (like discover weekly) to add all songs to your collection
// Just press F12 in Chrome and paste code to console
// only works on pages that use .btn class only
var addButtons = document.querySelectorAll('tr:not(.added) .btn.btn-icon.btn-add:not(.added)');
for (var i=0; i<addButtons.length; i++) {
addButtons[i].click()
}
// or use this
function favoriteAll() {
console.log('favoriting all');
var addButtons = Array.prototype.slice.call(document.querySelectorAll('tr:not(.added) .button-icon-only.button-add:not(.added), tr:not(.added) .btn.btn-icon.btn-add:not(.added)')).filter(function(button) {
return button.dataset.logClick === 'add-button';
});
for (var i=0; i<addButtons.length; i++) {
addButtons[i].click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment