Skip to content

Instantly share code, notes, and snippets.

@litvinovvo
Created August 23, 2020 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litvinovvo/d02b8a9d130eabd6877bed38230b0d20 to your computer and use it in GitHub Desktop.
Save litvinovvo/d02b8a9d130eabd6877bed38230b0d20 to your computer and use it in GitHub Desktop.
add vk audio to the given playlist
// scroll down fully
var songs = document.querySelectorAll('.audio_row');
var playlistId = '15359214_51903820';
for (var i = songs.length - 1; i >= 0; i--) {
console.log(i, 'more');
const mouseoverEvent = new Event('mouseover');
songs[i].dispatchEvent(mouseoverEvent);
await new Promise((a)=>setTimeout(a, 500));
songs[i].querySelector('.audio_row__action_more').click();
await new Promise((a)=>setTimeout(a, 500));
songs[i].querySelector('.audio_row__more_action_add_to_playlist').click();
await new Promise((a)=>setTimeout(a, 1500));
if (!songs[i].querySelector('.audio_row__more_action_pl_' + playlistId).classList.contains('audio_row__more_playlist_added')) {
songs[i].querySelector('.audio_row__more_action_pl_' + playlistId).click()
}
await new Promise((a)=>setTimeout(a, 500));
songs[i].remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment