Skip to content

Instantly share code, notes, and snippets.

@luttje
Last active April 3, 2021 18:00
Show Gist options
  • Select an option

  • Save luttje/8dfdcc184ecae1b9b14ca39c482118cc to your computer and use it in GitHub Desktop.

Select an option

Save luttje/8dfdcc184ecae1b9b14ca39c482118cc to your computer and use it in GitHub Desktop.
Remove all Facebook friends (one-by-one)
/*
Note: Only works for Dutch language settings on account of 'Vrienden' and 'Bevestigen' on line 12 and 14.
1. Go to your friends page on facebook: https://www.facebook.com/YOURUSERNAME/friends
2. Change the string after CONFIRM_IN_MY_LANGUAGE_IS below to what the confirmation dialog has as a 'Confirm' button.
3. Copy that code to the browser console
4. One by one friends will start getting removed
This script is trash and will get into a dead-lock sometimes. When that inevitably happens refresh the page and restart the script.
*/
const CONFIRM_IN_MY_LANGUAGE_IS = 'Bevestigen';
let currentAction = 0;
let actions = [
() => document.querySelector('div[data-pagelet="ProfileAppSection_0"] i[style^=\'background-image: url("https://static.xx.fbcdn.net/rsrc.php/v3/yX/r/sjwIelw3nbI.png"); background-position: 0px -133px\']').click(),
() => document.querySelector('[role="menuitem"]:last-child').click(),
() => document.querySelector('[aria-label="'+CONFIRM_IN_MY_LANGUAGE_IS+'"]').click(),
];
function nextAction(){
let next = actions[currentAction];
if(next){
try{
console.log('executing action ' + currentAction);
next();
currentAction++;
}catch{
console.log('failed action ' + currentAction + ' retrying');
setTimeout(nextAction, 500);
}
}else{
currentAction = 0;
nextAction();
}
}
window.onkeydown= function(e){
// 66 = B(ye)
if(e.keyCode === 66){
nextAction();
e.stopPropagation();
};
};
setInterval(nextAction, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment