diff --git a/assets/lastplayed.js b/assets/lastplayed.js new file mode 100644 index 0000000..5076da2 --- /dev/null +++ b/assets/lastplayed.js @@ -0,0 +1,11 @@ +const lastPlayedBlock = document.getElementById('last-played'); +let xmlHttp = new XMLHttpRequest(); +xmlHttp.open("GET", "https://lastfm-last-played.biancarosa.com.br/catmpeg/latest-song", false); +xmlHttp.send(null); +if (xmlHttp.responseText != 0) { + const lastParse = JSON.parse(xmlHttp.responseText); + + const lastPlayed = document.querySelector("#song"); + lastPlayed.innerHTML = "" + lastParse["track"]["name"] + " - " + lastParse["track"]["artist"]["#text"] + ""; + lastPlayedBlock.style.display = "block"; +} \ No newline at end of file diff --git a/index.html b/index.html index d2dfe29..24e94e6 100644 --- a/index.html +++ b/index.html @@ -30,23 +30,7 @@