Last active
August 29, 2015 14:11
-
-
Save sroucheray/581f022e06fd538eef33 to your computer and use it in GitHub Desktop.
How to collect Fans of a Facebook page
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
/* | |
Note : based on this script, there is a big gap between the number of returned profiles | |
and the counter that Facebook displays on Pages. | |
*/ | |
/* | |
To collect Fan's ID of a Facebook page (provided you are admin of the page), | |
open this page swapping YOUR_PAGE_ID with... your page id | |
https://www.facebook.com/browse/page_fans/?page_id=YOUR_PAGE_ID | |
and then dump JS bellow in Firebug or Chrome console en execute | |
*/ | |
window.NodeList.prototype.forEach = window.Array.prototype.forEach; | |
var profiles = []; | |
function evaluation() { | |
document.querySelectorAll(".fbProfileBrowserListItem").forEach(function(item, index) { | |
var profile = item.querySelector("a").getAttribute("href"); | |
profiles.push(profile.match(/https:\/\/www.facebook.com\/(.*)/)[1]); | |
item.parentNode.removeChild(item); | |
}); | |
if(document.querySelector(".uiMorePagerPrimary").click){ | |
document.querySelector(".uiMorePagerPrimary").click(); | |
} | |
return profiles; | |
}; | |
function evaluate(){ | |
evaluation(); | |
console.log("Grabbed", profiles.length); | |
timeout = window.setTimeout(evaluate, 500); | |
} | |
var timeout = window.setTimeout(evaluate, 500); | |
/* end */ |
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
// When you think you reached the number of profile you wanted just dumped this and execute | |
clearTimeout(timeout); | |
profiles.join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment