Created
November 11, 2019 16:06
-
-
Save phoebejaffe/949d6c91cfbcda065193b0a39e3638bb to your computer and use it in GitHub Desktop.
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
| // Run this on https://www.musicgenreslist.com/ to select a random genre and search spotify for it | |
| let genres, chooseGenre; | |
| genres = genres || Array.from(document.getElementsByTagName('li')) | |
| .filter(elem => elem.innerHTML === elem.textContent); | |
| chooseGenre = chooseGenre || (() => { | |
| const choice = genres[Math.floor(Math.random() * genres.length)]; | |
| const parenIndex = choice.textContent.indexOf(' ('); | |
| const text = parenIndex < 0 ? choice.textContent : choice.textContent.slice(0, parenIndex); | |
| const doIt = confirm(text + '?'); | |
| if (!doIt) { | |
| chooseGenre(); | |
| return; | |
| } | |
| const escapedText = escape((text).trim()); | |
| window.open(`https://open.spotify.com/search/${escapedText}/playlists`); | |
| }) | |
| chooseGenre(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment