Created
October 1, 2014 18:24
-
-
Save jayeb/c63b5f15bbd224e52b25 to your computer and use it in GitHub Desktop.
Google Play Music: Jump to random album
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
(function() { | |
var w = window, | |
getRandomAlbum = function() { | |
var albums, r, rAlbum; | |
if (w.location.hash == '#/albums') { | |
albums = document.querySelectorAll('div[data-type="album"]'); | |
r = Math.random(); | |
rAlbum = albums[Math.floor(r * albums.length)]; | |
w.removeEventListener('hashchange', getRandomAlbum, false); | |
w.location.hash = '/album/' + rAlbum.dataset.id; | |
} | |
}; | |
if (window.location.hash == '#/albums') { | |
getRandomAlbum(); | |
} else { | |
w.addEventListener('hashchange', getRandomAlbum, false); | |
w.location.hash = '/albums'; | |
} | |
})(); |
Sadly, this doesn't work anymore :(
Did you ever find a way to make it work?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When run on a Google Play Music tab, this script will take you to a random album page. It works great at a bookmarklet!
Just run the above code through a minifier (http://closure-compiler.appspot.com/home is a good place to start), then add a new bookmark prepended with
javascript:
, like so: