Created
April 30, 2017 16:54
-
-
Save petr-kalinin/e92ba8de95cd393c258150a450a7c7bc 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
elements = document.getElementsByClassName('audio_row'); | |
var cmd = "" | |
function log(elid, s) { | |
var re = /.*<!json>(.*)<!>/ | |
var match = re.exec(s) | |
res = JSON.parse(match[1]) | |
fname = res[0][4] + "-" + res[0][3] | |
fname = fname.replace("/", "") | |
console.log("logging ", res) | |
cmd += "echo " + elid + "\n" | |
cmd += "wget '" + res[0][2] + "' -O '" + fname + "_" + elid + ".mp3'\n" | |
cmd += "sleep 1.5\n" | |
} | |
var elid = 0 | |
function run() { | |
var el = elements[elid] | |
elid++ | |
if (elid > elements.length) { | |
console.log(cmd) | |
return | |
} | |
var id = el.getAttribute("data-full-id") | |
var url = "https://vk.com/al_audio.php"; | |
var params = "act=reload_audio&al=1&ids=" + id | |
console.log("elid=" + elid + "sending " + id) | |
var xhr = new XMLHttpRequest(); | |
xhr.open("POST", url, true); | |
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
xhr.onreadystatechange = function() { | |
if(xhr.readyState == 4 && xhr.status == 200) { | |
console.log(xhr.responseText) | |
log(elid, xhr.responseText); | |
} | |
} | |
xhr.send(params); | |
setTimeout(run, 1500) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment