Created
October 10, 2009 18:02
-
-
Save moustaki/206985 to your computer and use it in GitHub Desktop.
This file contains 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
// ==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