Skip to content

Instantly share code, notes, and snippets.

@rustcohlnikov
Created May 2, 2020 11:37
Show Gist options
  • Save rustcohlnikov/ba25b3a665ee6a1b9275cf6d47fb984f to your computer and use it in GitHub Desktop.
Save rustcohlnikov/ba25b3a665ee6a1b9275cf6d47fb984f to your computer and use it in GitHub Desktop.
Download VK music titles as text file
// 1. Manually scroll down and load all the music on your library
// 2. Paste code into console and hit Enter
// 3. Type `getMusic()`
// 4. `music.txt` files is downloaded
function getMusic() {
let songs = [];
let nodes = document.querySelectorAll('div.audio_row_content');
for (let index = 0; index < nodes.length; index++) {
const element = nodes[index];
const songName = element.querySelector('.audio_row__title_inner').textContent;
const artistName = element.querySelector('.audio_row__performer_title a').textContent;
songs.push(`${artistName} - ${songName}`);
}
const a = document.createElement('a');
a.download = 'music.txt';
const objectUrl = URL.createObjectURL(new Blob([songs.join("\n")], { type: 'text/plain' }));
a.href = objectUrl;
a.click();
delete a;
URL.revokeObjectURL(objectUrl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment