Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Muhammad Hamza
- * Usage:
- * Go to https://www.facebook.com/friends/requests/
- * Run the following code
- */
- function acceptRequests (container, mutualThreshold, timerDelay) {
- var rows = container.querySelectorAll('[aria-label="Confirm"]:not([aria-disabled="true"])')
- rows.forEach((row, index) => {
- try {
- if (mutualThreshold > 0) {
- const friendsCountLabel = row.closest('a').querySelector('[aria-labelledby$="friends"]')
- const friendsCount = Number(friendsCountLabel.getAttribute('aria-labelledby').split(' mutual')[0]);
- if (friendsCount < mutualThreshold) {
- return;
- }
- }
- setTimeout(() => {
- row.click();
- if (index === rows.length - 1) {
- container.scrollTop = container.scrollHeight;
- }
- }, index * timerDelay)
- }
- catch (e) {
- console.log(e);
- }
- })
- }
- function acceptAllFriendRequests (containerClass, mutualThreshold = 0, timerDelay = 500) {
- var container = document.querySelectorAll(containerClass);
- container = container[container.length - 1]
- acceptRequests(container, mutualThreshold, timerDelay);
- setInterval(() => {
- acceptRequests(container, mutualThreshold, timerDelay);
- }, 7000)
- }
- /**
- * Make sure to pass the correct css selector for the container element of the friend requests row
- */
- acceptAllFriendRequests('.rpm2j7zs.k7i0oixp.gvuykj2m', 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement