main #8
4 changed files with 12 additions and 15 deletions
9
astro/public/scripts/lastfm.js
Normal file
9
astro/public/scripts/lastfm.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
const user = "limepotato";
|
||||
const url = `https://lastfm-last-played.biancarosa.com.br/${user}/latest-song`;
|
||||
const song = document.querySelector("#song");
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
song.innerHTML =
|
||||
`${json.track.name} - ${json.track.artist["#text"]}`;
|
||||
});
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
<!-- optimized -->
|
||||
<script src="../scripts/lastfm.js"></script>
|
||||
<script src="../scripts/sound.js"></script>
|
||||
|
||||
<!-- unoptimized -->
|
||||
<script is:inline src="/scripts/ntfy.js"></script>
|
||||
<script is:inline src="/scripts/sga.js"></script>
|
||||
<script is:inline src="/scripts/lastfm.js"></script>
|
||||
<script is:inline src="/scripts/sound.js"></script>
|
|
@ -1,12 +0,0 @@
|
|||
let user = "limepotato";
|
||||
let url =
|
||||
"https://lastfm-last-played.biancarosa.com.br/" + user + "/latest-song";
|
||||
let song = document.querySelector("#song");
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (json) {
|
||||
song.innerHTML =
|
||||
json["track"]["name"] + " - " + json["track"]["artist"]["#text"];
|
||||
});
|
Loading…
Reference in a new issue