Skip to content

Instantly share code, notes, and snippets.

@bohwaz
Created January 9, 2025 18:03
Show Gist options
  • Save bohwaz/afcbc9c7dbca169c60cf7ed9f69ea507 to your computer and use it in GitHub Desktop.
Save bohwaz/afcbc9c7dbca169c60cf7ed9f69ea507 to your computer and use it in GitHub Desktop.
Delete all photos from your Facebook profile (French)
// Facebook is fascist network AND makes it super hard to delete all your photos!
// Here is a script that will automatically click on buttons
// to delete all your photos one by one from your Facebook account.
//
// 1. Click on the "Photos" tab of your Facebook profile
// 2. Click on the pencil on the right-top corner of a photo
// 3. Note the label of the button to delete a photo
// 4. Click on this button
// 5. Note the label of the confirm button
// 6. Change the following three labels to match the real buttons labels,
// according to your language (here it's in French)
var photo_menu_label = "Modifier"; // (should be "Edit" or "Modify" in English)
var photo_delete_label = "Supprimer la photo";
var photo_confirm_delete_label = "Supprimer";
// 7. Press F12 on your keyboard to open the developer tools
// 8. Open the console tab if it's not already open, and focus on the command prompt (last line at the bottom)
// 9. Copy and paste all of this code (including the labels above) and press enter
// That's it : it will take approximately 7 seconds to delete a photo, so it might be long.
// If the process fails and stops, just reload the page copy/paste + run the code again.
while(true) {
var menu = document.querySelector('[aria-label="' + photo_menu_label + '"]');
if (!menu) {
alert('No photo found');
break;
}
menu.click();
await new Promise(r => setTimeout(r, 1000));
var buttons = document.evaluate("//span[contains(., '" + photo_delete_label + "')]", document, null, XPathResult.ANY_TYPE, null );
var button = buttons.iterateNext();
button.click();
await new Promise(r => setTimeout(r, 1000));
// First one is a hidden fake button! obviously designed by Facebook to limit scripts!
document.querySelectorAll('[aria-label="' + photo_confirm_delete_label + '"]')[1].click();
await new Promise(r => setTimeout(r, 5000));
}
@effariwhy
Copy link

Thank you. I plan to give this a try later.

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