Skip to content

Instantly share code, notes, and snippets.

@antoniopresto
Created November 20, 2019 12:50
Show Gist options
  • Save antoniopresto/239f72c7fa055a944a638ead43b09a21 to your computer and use it in GitHub Desktop.
Save antoniopresto/239f72c7fa055a944a638ead43b09a21 to your computer and use it in GitHub Desktop.
shuffle all songs on spotify library
/**
* paste in the browser console and hit enter
*/
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 !== 0) return;
const playlists = [...document.querySelectorAll('[aria-label="Play"]')];
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