Created
November 20, 2019 12:50
-
-
Save antoniopresto/239f72c7fa055a944a638ead43b09a21 to your computer and use it in GitHub Desktop.
shuffle all songs on spotify library
This file contains 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
/** | |
* 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