mirror of
https://github.com/catmpeg/catmpeg.github.io.git
synced 2026-02-20 07:40:56 +03:00
do
This commit is contained in:
parent
7e899a508a
commit
2d5fc8d406
1 changed files with 11 additions and 9 deletions
|
|
@ -1,11 +1,13 @@
|
|||
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 = "<a target=\"blank_\" href=\"" + lastParse["track"]["url"] + "\">" + lastParse["track"]["name"] + " - " + lastParse["track"]["artist"]["#text"] + "</a>";
|
||||
lastPlayedBlock.style.display = "block";
|
||||
}
|
||||
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 = `<a target="_blank" href="${data.track.url}">
|
||||
${data.track.name} - ${data.track.artist["#text"]}</a>`;
|
||||
lastPlayedBlock.style.display = "block";
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
Loading…
Add table
Add a link
Reference in a new issue