Skip to content

Instantly share code, notes, and snippets.

@maggiben
Created November 6, 2015 19:43
Show Gist options
  • Save maggiben/4dccdf32309506b3296c to your computer and use it in GitHub Desktop.
Save maggiben/4dccdf32309506b3296c to your computer and use it in GitHub Desktop.
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();
}
}
archive = document.querySelectorAll('.archive')
var text = '';
Array.prototype.slice.call(archive).forEach(function(list){
var names = list.nextElementSibling.querySelectorAll('li');
Array.prototype.slice.call(names).forEach(function(name) {
//console.log(name.textContent)
text = text + "['" + name.textContent + "'], ";
})
})
download('list.txt', text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment