Skip to content

Instantly share code, notes, and snippets.

@max-frai
Created May 1, 2017 12:33
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save max-frai/bda8c6ed8555694150c3e37379f83fb5 to your computer and use it in GitHub Desktop.
Save max-frai/bda8c6ed8555694150c3e37379f83fb5 to your computer and use it in GitHub Desktop.
Auto add facebook suggested friends
// Run at this location: https://www.facebook.com/?sk=ff
var addFriendsCount = 100;
var addPause = 3 * 1000;
function waitForScroll() {
return new Promise(function(resolve, reject) {
var it = 0;
var interval = window.setInterval(function() {
console.log('Wait...');
if (it++ > 15)
{
window.clearInterval(interval);
resolve();
}
window.scrollBy(0, 2000);
}, 800, resolve);
});
}
waitForScroll().then(function() {
var added = 0;
var addFriends = document.querySelectorAll('#fbSearchResultsBox button.FriendRequestAdd');
addFriends = Array.prototype.slice.call(addFriends).reverse();
var clickInterval = window.setInterval(function() {
if (!addFriends.length || added++ == addFriendsCount)
{
window.clearInterval(clickInterval);
return;
}
var button = addFriends.pop();
button.scrollIntoView(false);
button.click();
console.log('Send request #' + added);
try{document.querySelector('div[role="dialog"] a.layerCancel').click()}catch(e){};
}, addPause);
});
@DirtyRoss
Copy link

Макс, будь добр допиши пожалуйста пару строк в скрипт, что бы он фильтровал по городу кол-ву общих друзей.
В моем случае город Киев, кол-во общих от 5

@themkvz
Copy link

themkvz commented May 17, 2017

что бы он фильтровал по городу кол-ву общих друзей.
В моем случае город Киев, кол-во общих от 5

А вот это хорошая идея. Тоже такой хочу :)

@dospolov
Copy link

dospolov commented Aug 29, 2018

@vilyam1
Copy link

vilyam1 commented Oct 2, 2018

Уже не работает! Выдает ошибку Uncaught SyntaxError: Unexpected identifier

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