diff --git a/src/spotify.js b/src/spotify.js index 059d726..8a4cfb1 100644 --- a/src/spotify.js +++ b/src/spotify.js @@ -218,9 +218,25 @@ async function _loadSpotifyTrackArtwork(tracks, listEl) { if (match.releaseDate) t.releaseDate = match.releaseDate; if (match.trackNumber) t.trackNumber = match.trackNumber; if (match.trackExplicitness) t.trackExplicitness = match.trackExplicitness; + if (match.previewUrl) t.previewUrl = match.previewUrl; if (window._spotifyResolved?.tracks?.[idx]) Object.assign(window._spotifyResolved.tracks[idx], t); const url = match.artworkUrl100 || match.artworkUrl60 || ''; if (url) _setArt(artEls[idx], url); + if (match.previewUrl) { + const item = artEls[idx]?.closest('.gtrack-item'); + if (item && !item.querySelector('.gtrack-actions .icon-btn.blue')) { + const actions = item.querySelector('.gtrack-actions'); + if (actions) { + const btn = document.createElement('button'); + btn.className = 'icon-btn blue'; + btn.title = '30s Preview'; + btn.innerHTML = ''; + btn.onclick = (e) => { e.stopPropagation(); window.playPreview(t); }; + actions.insertBefore(btn, actions.firstChild); + item.onclick = () => window.playPreview(t); + } + } + } } catch { /* non-critical */ } })); }