Skip to content

Instantly share code, notes, and snippets.

@printminion
Last active December 10, 2015 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save printminion/4409656 to your computer and use it in GitHub Desktop.
Save printminion/4409656 to your computer and use it in GitHub Desktop.
parse Snapbird Tweets
/**
* @desc parse Snapbird Tweets
* run it in the console after injecting jquery: https://gist.github.com/4141199
* @author Misha M.-Kupriyanov https://plus.google.com/104512463398531242371/
* @require jQuery
* @link https://gist.github.com/4409656
*/
var $content = null;
var $published = null;
var $url = null;
var output = '';
$('div#tweets div.tweet').each(function(key, node) {
$content = $('span.entry-content', this).text();
$published = $('span.published', this).attr('title');
$url = $('a.entry-date', this).attr('href');
var row = convertTimestamp($published) + '\t' + $content + '\t' + $url;
row = row.replace('\n', ' ');
output += row + '\n';
$content = null;
$published = null;
$url = null;
});
//open window with formatted output
var newWindow = window.open("","Test","width=300,height=300,scrollbars=1,resizable=1");
newWindow.document.open('text/plain');
newWindow.document.write('<pre>' + output + '</pre>');
newWindow.document.close();
/**
* convert timestamp
*/
function convertTimestamp(timestamp) {
var result = '';
var date = new Date(timestamp);
timestamp = timestamp.split(" ");
result = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear() + ' ' + timestamp[3];
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment