Created
August 6, 2017 10:23
-
-
Save netsi1964/24830520fbf2138e77d309eda0fcb974 to your computer and use it in GitHub Desktop.
Console snippet: Get Facebook Group information
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
var sel = "div > div > div > div.clearfix > div._gll > a"; | |
var count = "div._glm > div"; | |
var desc = "div._glo > div"; | |
var groups = Array.from(document.querySelectorAll(sel)); | |
var foundInfo = {}; | |
var json = ""; | |
groups.map(ele => { | |
var members = ele.parentNode.parentNode.parentNode | |
.querySelector(count) | |
.innerText.split(" ")[0]; | |
var description = ele.parentNode.parentNode.parentNode.querySelector(desc); | |
description = description | |
? description.innerText.trim() | |
: "Ingen beskrivelse"; | |
if (members > 10) { | |
var obj = { | |
members, | |
href: ele.href, | |
name: ele.innerText, | |
desc: description | |
}; | |
foundInfo[ele.innerText] = obj; | |
json += (json !== "" ? "," : "") + JSON.stringify(obj); | |
} | |
}); | |
var html = "<ul>"; | |
Object.keys(foundInfo).sort().map(key => { | |
let group = foundInfo[key]; | |
html += `<li><a href="${group.href}" target="_blank">${group.name}</a> - ${group.members} medlemmer</li>`; | |
}); | |
copy(html + "</ul>"); | |
copy(json); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment