Created
April 8, 2024 00:15
-
-
Save iamvinny/bfbba07e188c4649747b8fd701b56428 to your computer and use it in GitHub Desktop.
Cancel all sent friend requests on facebook
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
// Select all elements with the 'aria-label' attribute set to 'Cancel request' | |
const cancelButtons = Array.from(document.querySelectorAll('[aria-label="Cancel request"]')); | |
console.log(cancelButtons.length, 'Cancel request buttons found'); | |
// Function to click each button with a specified interval | |
function clickButtonsWithInterval(buttons, interval) { | |
let index = 0; | |
const intervalId = setInterval(() => { | |
if (index >= buttons.length) { | |
clearInterval(intervalId); // Stop when all buttons are clicked | |
console.log('All cancel requests processed.'); | |
} else { | |
console.log(`Clicking button ${index + 1}/${buttons.length}`); | |
buttons[index].click(); // Click the current button | |
index++; | |
} | |
}, interval); | |
} | |
// Execute the function with the found buttons and an interval of 300 milliseconds | |
clickButtonsWithInterval(cancelButtons, 300); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment