(function () { var e = "blha303"; window.lfmRecentTrack = function (t) { var n = (new Array).concat(t.recenttracks.track)[0]; var album, spurl, isgdurl; if (n.album["#text"]) { album = " (from " + n.album["#text"] + ")"; } else { album = ""; } try { var isgd = new XMLHttpRequest(); isgd.open("GET", "https://blha303.kd.io/isgd.php?url=" + encodeURIComponent(n.url), false); isgd.send(); isgdurl = " " + isgd.responseText; } catch(e) { console.log("isgd: " + e.message); isgdurl = " " + n.url; } try { var spotify = new XMLHttpRequest(); spotify.open("GET", "https://ws.spotify.com/search/1/track.json?q=" + encodeURIComponent(n.artist["#text"] + " - " + n.name), false); spotify.send(); var spotresp = JSON.parse(spotify.responseText); if (spotresp["tracks"].length > 0) { var urisplit = spotresp["tracks"][0]["href"].split(":"); spurl = " https://open.spotify.com/" + urisplit[1] + "/" + urisplit[2]; } else { console.log("spotify: couldn't get url"); spurl = ""; } } catch(e) { console.log("spotify: " + e.message); spurl = ""; } var r = "is listening to " + n.artist["#text"] + " - " + n.name + album + spurl + isgdurl; cb().say("/me " + r); } var n = document.createElement("script"); n.setAttribute("type", "text/javascript"); n.setAttribute("src", "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=" + e + "&api_key=891a3154063e53a608e393b7ec9552f9&limit=1&format=json&callback=window.lfmRecentTrack"); document.body.appendChild(n) })()