Skip to content

Commit

Permalink
fix object return value is not iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfung1031 authored and cvzi committed Apr 25, 2024
1 parent 76c9c88 commit 4195a20
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions SpotifyGeniusLyrics.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ async function openAndAskToSubmitSpotifyLyrics (songTitle, songArtistsArr, force
function submitLyricsFromMenu () {
genius.f.closeModalUIs()

const [songTitle, songArtistsArr] = getSongTitleAndArtist()
const [ret, songTitle, songArtistsArr] = getSongTitleAndArtist()
if (ret < 0) return

if (songTitle && document.querySelector('[data-testid="lyrics-button"]')) {
openAndAskToSubmitSpotifyLyrics(songTitle, songArtistsArr, true)
Expand Down Expand Up @@ -319,19 +320,19 @@ function getSongTitleAndArtist () {
const songTitleDOM = nowPlayingFooter ? HTMLElement.prototype.querySelector.call(nowPlayingFooter, songTitleQuery) : document.querySelector(songTitleQuery) // eslint-disable-line no-undef
if (!songTitleDOM) {
console.warn('The song title element is not found.')
return
return [-1]
}
const songTitle = genius.f.cleanUpSongTitle(songTitleDOM.textContent)
if (!songTitle) {
console.warn('The song title is empty.')
return
return [-2]
}
const songArtistsArr = []
const ArtistLinks = nowPlayingFooter ? HTMLElement.prototype.querySelectorAll.call(nowPlayingFooter, songArtistsQuery) : document.querySelectorAll(songArtistsQuery) // eslint-disable-line no-undef
for (const e of ArtistLinks) {
songArtistsArr.push(e.textContent)
}
return [songTitle, songArtistsArr]
return [0, songTitle, songArtistsArr]
}

function addLyrics (force, beLessSpecific) {
Expand All @@ -348,7 +349,8 @@ function addLyrics (force, beLessSpecific) {
}
})
}
const [songTitle, songArtistsArr] = getSongTitleAndArtist()
const [ret, songTitle, songArtistsArr] = getSongTitleAndArtist()
if (ret < 0) return
genius.f.loadLyrics(force, beLessSpecific, songTitle, songArtistsArr, musicIsPlaying)
}

Expand Down

0 comments on commit 4195a20

Please sign in to comment.