Skip to content

Instantly share code, notes, and snippets.

@fiatjaf fiatjaf/olavo.js
Last active Aug 29, 2015

Embed
What would you like to do?
garimpador de posts do olavo de carvalho
// 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
You can’t perform that action at this time.