Music Search Bookmarklets
Tools for searching Spotify or other music sites, using whatever text is currently selected
Larry Hamel, May 2024
Why
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.
How
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):
- Drag this "Selected text to Spotify search" link (or an alternative service link from the list below) into the "bookmarks bar".
- Or, on Firebox: Right-click on the "Selected text to Spotify search" link and choose "Bookmark Link".
- Or, via the Bookmark Manager: Use the browser's "Bookmark Manager" to create a new bookmark. In the URL field of that new bookmark, paste in the javascript snippet shown below. The text for the new bookmark is "Selected text to Spotify search" or whatever is preferred in the name.
- Or, on any browser, including mobile phones: Create a temporary bookmark by bookmarking any normal page, like this page. Then use the Bookmark Manager to edit that bookmark as described above.
Bookmarklets for searching various music sites
- Spotify for computer: Selected text to Spotify search
- Spotify for mobile: Selected text to Spotify search
- Selected text to Youtube search
- Selected text to Apple music search
- Selected text to Amazon music search
- Selected text to Pandora search
- Selected text to Deezer search
- Selected text to Bandcamp search
Technical Details
The javascript code is super simple and safe. It does 3 things:
- Copy the currently selected text (alert if nothing is selected).
- Add that text to the end of the search URL (and encode any spaces/punctuation)
- Open a new tab with that URL
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.
- https://open.spotify.com/search/ (on computer), https://open.spotify.com/search/results/ (on mobile)
- https://www.youtube.com/results?search_query=
- https://music.apple.com/us/search?term=
- https://music.amazon.com/search/
- https://www.pandora.com/search/
- https://www.deezer.com/search/
- https://bandcamp.com/search?q=
Mobile Phones
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.