Last active
July 16, 2024 17:20
-
-
Save hsayed21/b3ac020bc5f31716f192331c7dfaf3d1 to your computer and use it in GitHub Desktop.
Facebook Send Friend Request
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
// ==UserScript== | |
// @name Facebook Send Friend Request | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author @hsayed21 | |
// @match https://www.facebook.com/profile.php?id=*&sk=friends | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var minDelay = 5000; // Minimum delay of 5 seconds | |
var maxDelay = 15000; // Maximum delay of 15 seconds | |
var maxRequests = 20; // Maximum number of friend requests per session | |
var sessionDelay = 3600000; // Delay of 1 hour between sessions | |
var requestCount = 0; | |
// Function to get all friend request buttons and click them | |
var sendFriendRequests = function() { | |
if (requestCount < maxRequests) { | |
var friendButtons = document.querySelectorAll('div[aria-label="إضافة صديق"]'); | |
if (friendButtons.length > 0) { | |
clickButton(friendButtons, 0); | |
} else { | |
console.log("No friend request buttons found."); | |
} | |
} else { | |
console.log("Reached max requests for this session. Taking a break."); | |
requestCount = 0; | |
setTimeout(sendFriendRequests, sessionDelay); | |
} | |
}; | |
// Recursive function to click buttons with random delays | |
var clickButton = function(buttons, index) { | |
if (index < buttons.length && requestCount < maxRequests) { | |
buttons[index].click(); | |
requestCount++; | |
var delay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay; | |
setTimeout(function() { | |
clickButton(buttons, index + 1); | |
}, delay); | |
} else { | |
setTimeout(scrollToBottom, minDelay); | |
} | |
}; | |
// Function to scroll to the bottom of the page | |
var scrollToBottom = function() { | |
window.scrollTo(0, document.body.scrollHeight); | |
setTimeout(sendFriendRequests, minDelay); | |
}; | |
// Initial call | |
sendFriendRequests(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment