Larry Hamel, May 2024
Often, I want to hear samples from a band that I learn about from a venue website, an email, etc. That might mean typing the performer's name into a Spotify search page. To make this easier, there are now bookmarklets (small javascript snippets that fit into a bookmark) below that will search Spotify or other music services, using whatever text is currently selected in a web browser. I use such tools by selecting the name, and then clicking a bookmark that I previously installed in my browser on my computer.
Try it out now, using a computer (not mobile) by (1) selecting some
text on this page, such as the name below, and (2) clicking the "Selected text to Spotify
search" link. For example, here's an artist's name that I was happy to learn recently:
Brett Dennen
Selected
text to Spotify search
In order for this to work on any text on any web page, one of the bookmarklet links on this page
must be saved as a bookmark. (For mobile phones, a bookmarklet *may* work, but are harder to
install; see Mobile Phone section below.)
Installation techniques include the following four options; only the last one works for most mobile phones (and is the most difficult technique):
The javascript code is super simple and safe. It does 3 things:
javascript:{ const text = window.getSelection().toString().trim(); if (!text) { alert('Please select some text before running this bookmark'); } else { const url = 'https://open.spotify.com/search/' + encodeURIComponent(text); window.open(url, '_blank', 'noopener, noreferrer'); } }
Each of these services have a search URL. Some of the services seem to prefer encoding a space
character as "+" versus "%20", and some, like Spotify, seem to have different search URLs for
computer vs. mobile.
Mobile phones are challenging for bookmarklets. Some of the bookmarklets above work on some phones, and not others. For example, Chrome on Android is 100% failure as of the publishing date because the selection of text gets cleared when trying to select a bookmark. iPhones/iOS seem to be ok, although Spotify seems to want a different search URL for iPhones versus computers. One key reason for lack of mobile support for this kind of bookmarklet is the touch interface on mobile versus mouse/keyboard on computers.