Skip to content

Instantly share code, notes, and snippets.

@ichn-hu
Last active July 20, 2019 05:49
Show Gist options
  • Save ichn-hu/e20317591562bb285a280271694eb6da to your computer and use it in GitHub Desktop.
Save ichn-hu/e20317591562bb285a280271694eb6da to your computer and use it in GitHub Desktop.
Auto download vocabulary.com audio
var data = document.querySelector('.audio').attributes['data-audio'].value;
if (data) {
var url = 'https://audio.vocab.com/1.0/us/' + data + '.mp3';
var filename = document.title.split('-')[0].trim() + '.mp3';
download(filename, url);
}
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
else {
pom.click();
}
}
var data=document.querySelector('.audio').attributes['data-audio'].value;if(data){var url='https://audio.vocab.com/1.0/us/'+data+'.mp3';var filename=document.title.split('-')[0].trim()+'.mp3';download(filename,url)}function download(a,b){var c=document.createElement('a');c.setAttribute('href','data:text/plain;charset=utf-8,'+encodeURIComponent(b));c.setAttribute('download',a);if(document.createEvent){var d=document.createEvent('MouseEvents');d.initEvent('click',true,true);c.dispatchEvent(d)}else{c.click()}}

went to the webpage that you looked up for a word in vocabulary.com, then put the script in your console, hit enter, that's it.

thanks http://javascriptcompressor.com/ for compressing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment