Skip to content

Instantly share code, notes, and snippets.

@antoniopresto
Created August 30, 2019 11:01
Show Gist options
  • Save antoniopresto/367431c9965ddc0eeccace504d5acf1e to your computer and use it in GitHub Desktop.
Save antoniopresto/367431c9965ddc0eeccace504d5acf1e to your computer and use it in GitHub Desktop.
spotify shuffle all playlists, random all songs
/**
go to https://open.spotify.com/collection/playlists
and ast this in the browser console
**/
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutationRecord) {
window.onChangeProgressBar(
+mutationRecord.target.style.transform.split('.')[0].replace(/\D/gim, '')
);
});
});
var target = document.querySelector('.progress-bar__fg');
if (!target) {
throw new Error('progress-bar__fg does note exist');
}
observer.observe(target, { attributes: true, attributeFilter: ['style'] });
window.onChangeProgressBar = function(progress) {
if(progress > 1) return;
const playlists = [...document.querySelectorAll('.cover-art-playback')];
playlists[Math.floor(Math.random() * playlists.length)].click();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment