Skip to content

Instantly share code, notes, and snippets.

@digitalWestie
Last active June 6, 2017 14:35
Show Gist options
  • Save digitalWestie/727edadd5ee179062fa02c70abba2705 to your computer and use it in GitHub Desktop.
Save digitalWestie/727edadd5ee179062fa02c70abba2705 to your computer and use it in GitHub Desktop.
An example of using the Blob / createObjectURL web API: bundles tweets as a CSV and presents a download link;
var csvDownload = function(){
var t = $('p.TweetTextSize');
var CSV = [];
for (i = 0; i < t.length; i++) {
CSV.push('"' + t[i].innerText + '"');
}
CSV = CSV.join('\n');
window.URL = window.webkitURL || window.URL;
var contentType = 'text/csv';
var csvFile = new Blob([CSV], {type: contentType});
var a = document.createElement('a');
a.download = 'my.csv';
a.href = window.URL.createObjectURL(csvFile);
a.textContent = 'Download CSV';
a.style = "position:fixed; top:100px; left:100px; z-index:100000; background-color:black; color:white"
a.dataset.downloadurl = [contentType, a.download, a.href].join(':');
document.body.appendChild(a);
};
csvDownload();
@digitalWestie
Copy link
Author

digitalWestie commented Jun 6, 2017

Go to twitter.com, hit F12, and copy pasta this into the console, et voila, csv download link with the current tweet texts.

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