import{create,create2,get,$}from"/resources/lib";/* OLD SCHOOL CURRENT PLAYING STUFF *//* source: https://gist.github.com/trisweb/2c0c94273f653c81f34dbe8e85ad30e7 via https://www.trisweb.com/ *//* /other cool idea: changing color and contrast of tbe website background when pressing a key, tapping or clicking*/varLFM_API="https://ws.audioscrobbler.com/2.0/";varLFM_KEY="14eb0c0c914456103f2c584d930a44ba";// Get one at https://secure.last.fm/login?next=/api/account/createvarLFM_USER="jakeisnt";varrecentTracksUrl=LFM_API+"?method=user.getrecenttracks&user="+LFM_USER+"&api_key="+LFM_KEY+"+&format=json&limit=1";constLFM_TIMEOUT=1000*60;// 1 minuteconstlastfm=()=>{letnowPlayingNode: HTMLElement|null=null;functiongetNowPlaying(){get(recentTracksUrl,(response)=>{varcurrentTrack=response.recenttracks.track[0];// Check if it's the same, if not then rerenderif(!window["nowPlaying"]||window["nowPlaying"].mbid!=currentTrack.mbid){window["nowPlaying"]=currentTrack;renderNowPlaying(currentTrack);}setTimeout(getNowPlaying,LFM_TIMEOUT);});}functiongetMetadata(track){returncreate2("table",{className: "metadata-table"},create2("tr",{},create2("th",{},"Artist"),create2("td",{},track.artist["#text"])),create2("tr",{},create2("th",{},"Title"),create2("td",{},track.name)),create2("tr",{},create2("th",{},"Listened"),create2("td",{},track.date["#text"])));}functionrenderNowPlaying(track){console.log(track);if(nowPlayingNode){nowPlayingNode.remove();}nowPlayingNode=create("div",{className: "now-playing",href: track.url,target: "blank",},$(".lastfm-now-playing-box"));constnowPlayingImage=create("img",{className: "np-image",width: "128",height: "128",src: track.image.slice(-1)[0]["#text"],},nowPlayingNode);// const currently = track["@attr"] && track["@attr"].nowplaying == "true";if(nowPlayingNode){nowPlayingNode.appendChild(getMetadata(track));// const metadata = create('div', {// class: 'np-metadata',// innerHTML: getMetadata(track, currently),// }, nowPlayingNode);setTimeout(()=>{nowPlayingNode?.setAttribute("class","now-playing loaded");},100);}}getNowPlaying();};lastfm();