/**
 *
 *  ----------------------------------
 *  spotifyCurrentlyPlaying.js - v1.0.0
 *  ----------------------------------
 *
 *  Display your currently playing Spotify song using Last.fm scrobbling.
 *
 *  https://github.com/kjbrum/spotifyCurrentlyPlaying.js
 *  @license Copyright (c) Kyle Brumm <http://kylebrumm.com>
 *
 */
!function(t){var e=function(t,r,o,s,n){return new e.init(t,r,o,s,n)};e.prototype={displayPlayer:function(){if(!this.selector)throw"Missing selector";var t=this;this.queryLastfm(function(){t.searchSpotify(function(){if(""!=t.spotifyURI){"string"==typeof t.selector&&(container=document.querySelector(t.selector));var e=document.createElement("iframe");e.width=t.width,e.height=t.height,e.src="https://embed.spotify.com/?uri="+encodeURIComponent(t.spotifyURI),e.frameBorder=0,e.setAttribute("allowtransparency","true"),container.appendChild(e)}else console.log("No tracks were found on Spotify.")})})},queryLastfm:function(t){var e=this,r="http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user="+this.username+"&api_key="+this.api_key+"&limit=1&format=json",o=new XMLHttpRequest;o.open("GET",r,!0),o.onload=function(){var r=JSON.parse(o.responseText);if(!(o.status>=200&&o.status<400))throw r.message;var s;s=r.recenttracks.track[0]?r.recenttracks.track[0]:r.recenttracks.track,e.lastfmTrack={title:s.name,artist:s.artist["#text"],album:s.album["#text"]},t()},o.onerror=function(){throw"connection error"},o.send()},searchSpotify:function(t){var e=this,r="",o=e.lastfmTrack;for(var s in o)o.hasOwnProperty(s)&&o[s]&&(r+=s+":"+o[s]+" ");var n="https://api.spotify.com/v1/search?query="+encodeURIComponent(r)+"&offset=0&limit=1&type=track",i=new XMLHttpRequest;i.open("GET",n,!0),i.onload=function(){var r=JSON.parse(i.responseText);if(!(i.status>=200&&i.status<400))throw r.message;r.tracks.items[0]&&(e.spotifyURI=r.tracks.items[0].uri),t()},i.onerror=function(){throw"connection error"},i.send()}},e.init=function(t,e,r,o,s){var n=this;n.selector=t||"",n.username=e||"",n.api_key=r||"",n.width=o||"300",n.height=s||"400",n.lastfmTrack={title:"",artist:"",album:""},n.spotifyURI="",n.displayPlayer()},e.init.prototype=e.prototype,t.SpotifyCurrentlyPlaying=t.SCP=e}(window);

/**
 *
 *  -----------------------------------
 *  spotifyCurrentlyPlaying.js - v1.0.0
 *  -----------------------------------
 *
 *  Display your currently playing Spotify song using Last.fm scrobbling.
 *
 *  https://github.com/kjbrum/spotifyCurrentlyPlaying.js
 *  @license Copyright (c) Kyle Brumm <http://kylebrumm.com>
 *
 */
!function(t){var e=function(t,r,o,s,n){return new e.init(t,r,o,s,n)};e.prototype={displayPlayer:function(){if(!this.selector)throw"Missing selector";var t=this;this.queryLastfm(function(){t.searchSpotify(function(){var e=t.selector;if("string"==typeof t.selector&&(e=document.querySelector(t.selector)),t.spotifyURI="",""!=t.spotifyURI){var r=document.createElement("iframe");r.width=t.width,r.height=t.height,r.src="https://embed.spotify.com/?uri="+encodeURIComponent(t.spotifyURI),r.frameBorder=0,r.setAttribute("allowtransparency","true"),e.appendChild(r)}else{var o=document.createElement("p"),s=document.createTextNode("No track found.");o.appendChild(s),e.appendChild(o)}})})},queryLastfm:function(t){var e=this,r="http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user="+this.username+"&api_key="+this.api_key+"&limit=1&format=json",o=new XMLHttpRequest;o.open("GET",r,!0),o.onload=function(){var r=JSON.parse(o.responseText);if(!(o.status>=200&&o.status<400))throw r.message;var s;s=r.recenttracks.track[0]?r.recenttracks.track[0]:r.recenttracks.track,e.lastfmTrack={title:s.name,artist:s.artist["#text"],album:s.album["#text"]},t()},o.onerror=function(){throw"connection error"},o.send()},searchSpotify:function(t){var e=this,r="",o=e.lastfmTrack;for(var s in o)o.hasOwnProperty(s)&&o[s]&&(r+=s+":"+o[s]+" ");var n="https://api.spotify.com/v1/search?query="+encodeURIComponent(r)+"&offset=0&limit=1&type=track",i=new XMLHttpRequest;i.open("GET",n,!0),i.onload=function(){var r=JSON.parse(i.responseText);if(!(i.status>=200&&i.status<400))throw r.message;r.tracks.items[0]&&(e.spotifyURI=r.tracks.items[0].uri),t()},i.onerror=function(){throw"connection error"},i.send()}},e.init=function(t,e,r,o,s){var n=this;n.selector=t||"",n.username=e||"",n.api_key=r||"",n.width=o||"300",n.height=s||"400",n.lastfmTrack={title:"",artist:"",album:""},n.spotifyURI="",n.displayPlayer()},e.init.prototype=e.prototype,t.SpotifyCurrentlyPlaying=t.SCP=e}(window);

Update script