Skip to content

Instantly share code, notes, and snippets.

@moustaki
Created October 10, 2009 17:51
Show Gist options
  • Save moustaki/206980 to your computer and use it in GitHub Desktop.
Save moustaki/206980 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name /music recs
// @namespace http://moustaki.org/music-recs/
// @description Injects recommendations within /music
// @include http://www.bbc.co.uk/music/artists/*
// ==/UserScript==
var url = window.location.href;
artist_guid = url.split("artists\/")[1];
recs_url = "http://localhost:4567/recommendations/" + artist_guid;
GM_xmlhttpRequest({
method: "GET",
url: recs_url,
onload: function(responseDetails) {
if (responseDetails.status == 200) {
recs = responseDetails.responseText;
var elt = document.createElement('div');
elt.setAttribute('class', 'container');
elt.innerHTML = "<h2>Related artists</h2><p>" + recs + "</p>";
var rc = document.getElementById('bbc_related_content');
rc.insertBefore(elt, rc.firstChild);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment