Last active
August 29, 2015 13:59
-
-
Save fiatjaf/10605200 to your computer and use it in GitHub Desktop.
garimpador de posts do olavo de carvalho
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
// jquery | |
window.posts = {} | |
var fetch = function () { | |
$('div[role="article"] span.fcg span.fwb a[href^="https://www.facebook.com/olavo.decarvalho"]').each(function () { | |
var post = {} | |
var elem = $(this).closest('div[role="article"]') | |
if (!elem) return | |
post.url = elem.find('a.uiLinkSubtle').attr('href') | |
if (!post.url) return | |
post.id = post.url.split('/').slice(-1)[0].split('?')[0] | |
post.date = elem.find('a.uiLinkSubtle abbr').attr('title') | |
if (!post.date) return | |
post.utime = elem.find('a.uiLinkSubtle abbr').data('utime') | |
if (!post.utime) return | |
post.text = elem.find('div.userContentWrapper').text() | |
if (!post.text) return | |
window.posts[post.id] = post | |
console.log('fetched post ' + post.id) | |
}) | |
} | |
var scroll = function () { | |
window.scrollTo(0, document.body.scrollHeight) | |
} | |
var download = function () { | |
var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(window.posts)) | |
$('<a id="download-json" href="data:' + data + '" download="data.json">download JSON</a>').appendTo(document.body) | |
$('#download-json').click() | |
} | |
window.count = 0 | |
var main = function () { | |
scroll() | |
setTimeout(function () { | |
main() | |
window.count++ | |
}, 4500) | |
if (window.count > 150) { | |
fetch() | |
download() | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment