gistfile1.js
· 1.8 KiB · JavaScript
Raw
(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)
})()
| 1 | (function () { |
| 2 | var e = "blha303"; |
| 3 | window.lfmRecentTrack = function (t) { |
| 4 | var n = (new Array).concat(t.recenttracks.track)[0]; |
| 5 | var album, spurl, isgdurl; |
| 6 | if (n.album["#text"]) { |
| 7 | album = " (from " + n.album["#text"] + ")"; |
| 8 | } else { |
| 9 | album = ""; |
| 10 | } |
| 11 | try { |
| 12 | var isgd = new XMLHttpRequest(); |
| 13 | isgd.open("GET", "https://blha303.kd.io/isgd.php?url=" + encodeURIComponent(n.url), false); |
| 14 | isgd.send(); |
| 15 | isgdurl = " " + isgd.responseText; |
| 16 | } catch (e) { |
| 17 | console.log("isgd: " + e.message); |
| 18 | isgdurl = n.url; |
| 19 | } |
| 20 | try { |
| 21 | var spotify = new XMLHttpRequest(); |
| 22 | spotify.open("GET", "https://ws.spotify.com/search/1/track.json?q=" + encodeURIComponent(n.artist["#text"] + " - " + n.name), false); |
| 23 | spotify.send(); |
| 24 | var spotresp = JSON.parse(spotify.responseText); |
| 25 | if (spotresp["tracks"].length > 0) { |
| 26 | var urisplit = spotresp["tracks"][0]["href"].split(":"); |
| 27 | spurl = " https://open.spotify.com/" + urisplit[1] + "/" + urisplit[2]; |
| 28 | } else { |
| 29 | console.log("spotify: couldn't get url"); |
| 30 | spurl = ""; |
| 31 | } |
| 32 | } catch (e) { |
| 33 | console.log("spotify: " + e.message); |
| 34 | spurl = ""; |
| 35 | } |
| 36 | var r = "is listening to " + n.artist["#text"] + " - " + n.name + album + spurl + isgdurl; |
| 37 | cb().say("/me " + r); |
| 38 | } |
| 39 | var n = document.createElement("script"); |
| 40 | n.setAttribute("type", "text/javascript"); |
| 41 | n.setAttribute("src", "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=" + e + "&api_key=891a3154063e53a608e393b7ec9552f9&limit=1&format=json&callback=window.lfmRecentTrack"); |
| 42 | document.body.appendChild(n) |
| 43 | })() |
gistfile2.js
· 1.1 KiB · JavaScript
Raw
(function(){var e="blha303";window.lfmRecentTrack=function(e){var t=(new Array).concat(e.recenttracks.track)[0];var n,r,i;if(t.album["#text"]){n=" (from "+t.album["#text"]+")"}else{n=""}try{var s=new XMLHttpRequest;s.open("GET","https://blha303.kd.io/isgd.php?url="+encodeURIComponent(t.url),false);s.send();i=" "+s.responseText}catch(o){console.log("isgd: "+o.message);i=t.url}try{var u=new XMLHttpRequest;u.open("GET","https://ws.spotify.com/search/1/track.json?q="+encodeURIComponent(t.artist["#text"]+" - "+t.name),false);u.send();var a=JSON.parse(u.responseText);if(a["tracks"].length>0){var f=a["tracks"][0]["href"].split(":");r=" https://open.spotify.com/"+f[1]+"/"+f[2]}else{console.log("spotify: couldn't get url");r=""}}catch(o){console.log("spotify: "+o.message);r=""}var l="is listening to "+t.artist["#text"]+" - "+t.name+n+r+i;cb().say("/me "+l)};var t=document.createElement("script");t.setAttribute("type","text/javascript");t.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(t)})()
| 1 | (function(){var e="blha303";window.lfmRecentTrack=function(e){var t=(new Array).concat(e.recenttracks.track)[0];var n,r,i;if(t.album["#text"]){n=" (from "+t.album["#text"]+")"}else{n=""}try{var s=new XMLHttpRequest;s.open("GET","https://blha303.kd.io/isgd.php?url="+encodeURIComponent(t.url),false);s.send();i=" "+s.responseText}catch(o){console.log("isgd: "+o.message);i=t.url}try{var u=new XMLHttpRequest;u.open("GET","https://ws.spotify.com/search/1/track.json?q="+encodeURIComponent(t.artist["#text"]+" - "+t.name),false);u.send();var a=JSON.parse(u.responseText);if(a["tracks"].length>0){var f=a["tracks"][0]["href"].split(":");r=" https://open.spotify.com/"+f[1]+"/"+f[2]}else{console.log("spotify: couldn't get url");r=""}}catch(o){console.log("spotify: "+o.message);r=""}var l="is listening to "+t.artist["#text"]+" - "+t.name+n+r+i;cb().say("/me "+l)};var t=document.createElement("script");t.setAttribute("type","text/javascript");t.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(t)})() |