Adding Spotify links to BBC Radio playlists, via RDFa, using Greasemonkey and rdfQuery

This is a Greasemonkey script that

  1. Uses rdfQuery to read the RDFa from radio tracklist pages on
        .prefix('mo', '')
        .prefix('foaf', '')
        .prefix('dc', '')
        .where('?track a mo:Track')
        .where('?track foaf:maker ?artist')
        .where('?track dc:title ?trackTitle')
        .where('?artist a mo:MusicArtist')
        .where('?artist foaf:name ?artistName') // not quite working yet (rdfQuery bug)
        .each(function(i, bindings, triples) {
  2. Looks up that track using the Spotify metadata API:"' + encodeURIComponent(artistName) + '"+track:"' + encodeURIComponent(trackTitle) + '"'

    (when MusicBrainz ID searches are working better in Spotify, could use those instead)

  3. Replaces the artist name and track title of found tracks with Spotify links, and adds a Spotify link for the album on which the track was found.

Try it on one of these pages: