Skip to content

Instantly share code, notes, and snippets.

@kerolloz
Last active December 10, 2019 18:02
Show Gist options
  • Save kerolloz/733d36951a30b94efcc79003de4032c1 to your computer and use it in GitHub Desktop.
Save kerolloz/733d36951a30b94efcc79003de4032c1 to your computer and use it in GitHub Desktop.
This script parses posts in a Facebook group
function get_all_posts_content() {
let my_txt = "";
const posts = document.querySelectorAll("._5pbx.userContent");
for (const post of posts) {
my_txt += post.innerText + "\n-------------------\n"
}
return my_txt
}
function click_all_see_more() {
const see_mores = document.querySelectorAll(".see_more_link")
for (const see_more of see_mores) see_more.click()
}
function replace_with_full_links() {
// some long links won't be displayed, so we need to replace each link with its href link
const links = document.querySelectorAll("a[rel='noreferrer']")
for (const link of links) {
link.innerText = link.href;
}
}
// first we need to scroll all the page to see all the posts
click_all_see_more()
replace_with_full_links()
get_all_posts_content()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment