Last active
January 20, 2023 08:41
-
-
Save Kreozot/256bbe31ff4ba8cc50afbbd7cdf9d2f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TRACKS_SELECTOR = 'div.d-track__overflowable-column > div.d-track__overflowable-wrapper.deco-typo-secondary.block-layout'; | |
const TRACK_NAME_SELECTOR = '.d-track__title'; | |
const TRACK_VERSION_SELECTOR = '.d-track__version'; | |
const TRACK_ARTISTS_SELECTOR = '.d-track__artists > a'; | |
const trackElements = document.querySelectorAll(TRACKS_SELECTOR); | |
const tracks = []; | |
trackElements.forEach((trackElement) => { | |
const name = trackElement.querySelector(TRACK_NAME_SELECTOR).innerHTML.trim(); | |
const version = trackElement.querySelector(TRACK_VERSION_SELECTOR)?.innerHTML.trim(); | |
const artistElements = trackElement.querySelectorAll(TRACK_ARTISTS_SELECTOR); | |
const artists = []; | |
artistElements.forEach((artistElement) => artists.push(artistElement.innerHTML.trim())); | |
tracks.push({ | |
name, | |
version, | |
artists, | |
}); | |
}); | |
const result = tracks.map(({name, version, artists}) => `${artists.join(', ')}: ${name}${version ? ` (${version})` : ''}`); | |
const resultArrayString = JSON.stringify(result, null, 2); | |
navigator.clipboard.writeText(resultArrayString); | |
console.log(resultArrayString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment