Skip to content

Instantly share code, notes, and snippets.

@kindziora
Last active January 19, 2017 18:16
Show Gist options
  • Save kindziora/993263005176ba71438dce5525c82e30 to your computer and use it in GitHub Desktop.
Save kindziora/993263005176ba71438dce5525c82e30 to your computer and use it in GitHub Desktop.
download music from yandex music
function down(uri, name) {console.log(uri,name);
var link = document.createElement("a");
link.download = name;
link.href = uri;
link.click();
}
function links() {
var $tr = $('.page-album__tracks .track_selectable'), l = $tr.length;
var queue = {}, i = 1;
$tr.each(function() {
var $e = $(this);
queue[$e.find('.track__title.link').attr('href').split('/').pop()] = {
name : $e.attr('title'),
c: function($e) {
return function() {
console.log($e); $e.find('.icon_pp').trigger('click');
}
}($e)
};
console.log(i,l,queue);
if(++i >= l) run(queue);
});
}
function run(queue) {
var i = 0;
for (var id in queue) {
window.setTimeout(queue[id].c, 5000 * i++);
}
window.setTimeout(function() {
var list = performance.getEntriesByType("resource");
for (var i=0; i < list.length; i++) {
if(list[i].name.indexOf("get-mp3") !== -1){console.log(list[i]);
down(list[i].name, queue[list[i].name.split('track-id=')[1].split('&')[0]].name);
}
}
}, ++i * 4000);
}; links()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment