diff --git a/assets/lastplayed.js b/assets/lastplayed.js index f0b3b8f..6d1aa66 100644 --- a/assets/lastplayed.js +++ b/assets/lastplayed.js @@ -1,13 +1,15 @@ -const lastPlayedBlock = document.getElementById('last-played'); +document.addEventListener("DOMContentLoaded", () => { + const lastPlayedBlock = document.getElementById('last-played'); -fetch("https://lastfm-last-played.biancarosa.com.br/catmpeg/latest-song") - .then(response => response.json()) - .then(data => { - if (data != 0) { - const lastPlayed = document.querySelector("#song"); - lastPlayed.innerHTML = ` - ${data.track.name} - ${data.track.artist["#text"]}`; - lastPlayedBlock.style.display = "block"; - } - }) - .catch(err => console.error(err)); \ No newline at end of file + fetch("https://lastfm-last-played.biancarosa.com.br/catmpeg/latest-song") + .then(response => response.json()) + .then(data => { + if (data != 0) { + const lastPlayed = document.getElementById("song"); + lastPlayed.innerHTML = ` + ${data.track.name} - ${data.track.artist["#text"]}`; + lastPlayedBlock.style.display = "block"; + } + }) + .catch(err => console.error(err)); +}); \ No newline at end of file diff --git a/index.html b/index.html index 7f82adf..2930662 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,8 @@
-
+