Skip to content

Instantly share code, notes, and snippets.

@shiftgeist
Last active June 8, 2026 10:53
Show Gist options
  • Select an option

  • Save shiftgeist/b96190f0af72d45e05489b8131f42106 to your computer and use it in GitHub Desktop.

Select an option

Save shiftgeist/b96190f0af72d45e05489b8131f42106 to your computer and use it in GitHub Desktop.
Soundcloud: Add all liked songs to playlist
// 1. Start on https://soundcloud.com/you/likes
// 2. Scroll all the way to the bottom (may only add 300 items at a time because of soundcloud api)
// (playlists are limited to 500 songs)
playlistName = 'Likes' // <== your playlist
list = Array.from(document.querySelectorAll('.badgeList__item .sc-button-more'))
console.log('Found', list.length, 'liked songs')
function addToPlaylist(item) {
// open menu
item.click()
document.querySelector('.sc-button-addtoset').click()
setTimeout(() => {
playlists = Array.from(document.querySelectorAll('.addToPlaylistItem'))
playlist = playlists.find(p => {
titleLink = p.querySelector('.addToPlaylistItem__titleLink').innerText
return titleLink.toLowerCase() === playlistName.toLowerCase()
})
if (!playlist) {
console.error('No playlist with name', playlistName)
}
// click add to playlist after animation
button = playlist.querySelector('.addToPlaylistButton')
if (button.innerText.toLowerCase() === 'added') {
console.warn('Song already in playlist')
} else {
console.info('Song added to playlist')
button.click()
}
document.querySelector('.modal').click()
}, 300)
}
function delay(i) {
addToPlaylist(list[i])
if (i < list.length) {
setTimeout(() => {
i++;
delay(i);
}, 500);
} else {
console.warn('End of list reached', i)
}
}
delay(0)
@mccninja

mccninja commented Sep 7, 2025

Copy link
Copy Markdown

how do i use this

@mvainx

mvainx commented Sep 10, 2025

Copy link
Copy Markdown

How can I shorten down the list of tracks the program is looking through? Ive gotten a bunch of tracks now but it keeps timing out by the time I need to finish the rest.

@omrzgit

omrzgit commented Dec 28, 2025

Copy link
Copy Markdown

VM885:10 Uncaught TypeError: Cannot read properties of undefined (reading 'click')
at addToPlaylist (:10:8)
at delay (:41:3)
at :53:1

@onefckcps

Copy link
Copy Markdown

This script will be detected by soundcloud and you might get you ip banned:

We detected unusual activity from your device or network.

Reasons may include:

    Rapid taps or clicks
    JavaScript disabled or not working
    Automated (bot) activity on your network
    Use of developer or inspection tools

updated script:

// 1. Start on https://soundcloud.com/you/likes
// 2. Scroll all the way to the bottom (may only add 300 items at a time because of soundcloud api)
// (playlists are limited to 500 songs)

playlistName = 'Likes' // <== your playlist name

// Updated selector: SoundCloud removed .badgeList__item, use broader selector
list = Array.from(document.querySelectorAll('.soundActions .sc-button-more, button[title="More"]'))

// Deduplicate in case both selectors match the same elements
list = [...new Set(list)]

console.log('Found', list.length, 'liked songs')

if (list.length === 0) {
  console.error('No songs found! Try running this in the browser console on https://soundcloud.com/you/likes after scrolling to the bottom.')
}

function addToPlaylist(item) {
  // open "more" menu
  item.click()

  // Try both old and new selector for "Add to playlist" button
  const addToSetBtn = document.querySelector('.sc-button-addtoset, button[title="Add to playlist"]')
  if (!addToSetBtn) {
    console.error('Could not find "Add to playlist" button in menu')
    // close any open menu by pressing Escape
    document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }))
    return
  }
  addToSetBtn.click()

  setTimeout(() => {
    // Try both old and new selectors for playlist items
    playlists = Array.from(document.querySelectorAll('.addToPlaylistItem, [class*="addToPlaylist"]'))

    playlist = playlists.find(p => {
      const titleEl = p.querySelector('.addToPlaylistItem__titleLink, [class*="titleLink"]')
      if (!titleEl) return false
      return titleEl.innerText.toLowerCase() === playlistName.toLowerCase()
    })

    if (!playlist) {
      console.error('No playlist with name', playlistName)
      // close modal
      const modal = document.querySelector('.modal, [class*="modal"]')
      if (modal) modal.click()
      return
    }

    // click add to playlist after animation
    button = playlist.querySelector('.addToPlaylistButton, [class*="addToPlaylist"] button')

    if (!button) {
      console.error('Could not find add button in playlist item')
      return
    }

    if (button.innerText.toLowerCase() === 'added') {
      console.warn('Song already in playlist')
    } else {
      console.info('Song added to playlist')
      button.click()
    }

    const modal = document.querySelector('.modal, [class*="modal"]')
    if (modal) modal.click()
  }, 300)
}

function delay(i) {
  if (i >= list.length) {
    console.warn('End of list reached', i)
    return
  }

  addToPlaylist(list[i])

  setTimeout(() => {
    delay(i + 1)
  }, 500)
}

delay(0)

@zogaru

zogaru commented Jun 8, 2026

Copy link
Copy Markdown

Thank you for this, worked like a charm. I don't think there are many other options do add your liked tracks with automation around. Nicely done!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment