Created
October 31, 2016 06:09
-
-
Save haroldtreen/83a4ece070c5b61d92e41e78ddb575cf to your computer and use it in GitHub Desktop.
Easier downloading from hypem.com 🎵
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
(function() { | |
function getTracks() { | |
var tracks = []; | |
$('.section-player').each(function() { | |
tracks.push({ | |
title: $(this).find('.track_name').text().replace(/\s+/g, ' ').trim() + '.mp3', | |
url: $(this).find('.dl').find('a').attr('href'), | |
}); | |
}); | |
return tracks; | |
} | |
function downloadTrack(track) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', track.url, true); | |
xhr.responseType = 'blob'; | |
xhr.onload = function(e) { | |
var link = document.createElement('a'); | |
link.download = track.title; | |
link.href = (URL || webkitURL).createObjectURL(this.response); | |
link.target = '_blank'; | |
document.body.appendChild(link); | |
link.click(); | |
}; | |
xhr.send(); | |
} | |
var downloadLimit = Number(prompt('How many tracks to download?')); | |
getTracks().forEach(function(track, index) { | |
if (index < downloadLimit) { | |
downloadTrack(track); | |
} | |
}); | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a really handy Chrome Extension for adding download buttons to HypeMachine.
Unfortunately it has some problems:
Save Link As...
This bookmarklet:
It makes my life easier.
Maybe yours too ¯_(ツ)_/¯.