Skip to content

Instantly share code, notes, and snippets.

@davearel
Last active April 8, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davearel/b10dee8417a6d119072320df27d2f01c to your computer and use it in GitHub Desktop.
Save davearel/b10dee8417a6d119072320df27d2f01c to your computer and use it in GitHub Desktop.
Facebook Page - Share With Friends
/*
* Facebook Auto Share a Business Page
*
* This script can be run inside the console
* while on a Facebook business page.
* It will open the share with friends dialog and
* automatically begin requesting friends to like
* the given page.
*/
function contains(selector, text, el) {
el = el || document;
var elements = el.querySelectorAll(selector);
return [].filter.call(elements, function(element){
return RegExp(text).test(element.textContent);
});
}
/*
* Open share dialog
*/
function openMenu() {
var startButton = contains('#pages-header button', 'More')[0];
startButton.click();
var inviteFriendsButton = contains('.uiContextualLayerPositioner.uiLayer a', 'Invite Friends')[0];
inviteFriendsButton.click();
}
/*
* Loop through all invites and hit send
*/
function sendInvites() {
var form = document.querySelectorAll('form[action="/ajax/pages/invite/send/"]')[0];
var listItems = form.querySelectorAll('.lists .fbProfileBrowserResult .fbProfileBrowserListContainer ul li');
var i = 0;
listItems.forEach(function(item, index) {
var button = contains('a.uiButton', 'Invite', item);
if (button.length) {
setTimeout(function() {
button[0].click();
}, 1000*i);
}
});
}
openMenu();
// wait for all items to load
setTimeout(function() {
sendInvites();
}, 5000);
@davearel
Copy link
Author

davearel commented Apr 8, 2017

Step 1. Copy above code
Step 2. Go to facebook page (https://www.facebook.com/Codeverse-1741310786141107/)
Step 3. "⌘ + alt + i" to open console
Step 4. Click the "console" tab, and Paste code
Step 5. Press enter
Step 6. Refresh the page when you receive the message that you've sent too many requests
Step 7. Repeat later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment