Skip to content

Instantly share code, notes, and snippets.

@alex-bender
Last active April 26, 2016 16:58
Show Gist options
  • Save alex-bender/3dcf09a2c6d38e4a1318 to your computer and use it in GitHub Desktop.
Save alex-bender/3dcf09a2c6d38e4a1318 to your computer and use it in GitHub Desktop.
code for getting song list json from vk.com
var hiddenFields = document.getElementsByTagName("input");
var mp3s = [];
function getHiddenField(elem, index, collection){
if(elem.getAttribute("type") == "hidden" && (/audio_info\d+_\d+/).test(elem.getAttribute("id"))){
mp3s.push({
'artist': elem.parentElement.nextSibling.nextSibling.childNodes[1].childNodes[0].textContent,
'title': elem.parentElement.nextSibling.nextSibling.childNodes[1].childNodes[2].textContent,
'url': elem.getAttribute("value").split(",")[0].split('?')[0]
});
}
}
for(var i=0; i < hiddenFields.length; i++){
getHiddenField(hiddenFields[i], i, hiddenFields);
}
console.log(JSON.stringify(mp3s));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment