google-photos-delete-tool
google-photos-delete-tool copied to clipboard
Selects images, doesn't seem to delete them
I increased the timeouts by a factor of 2X. I see the photos selected, but I don't see the delete actions occur.
Rather it seems to repeatedly: Select the same images, clear upon deleation, and select those images again.
I checked and my language was set to US English. I set to English and the behavior was the same.
Maybe a side effect of using Chromium vs. Chrome?
Version 89.0.4389.82 (Official Build) Arch Linux (64-bit)
I experience the same on both Edge as Chrome. Console does prints it is deleting but it seems the actual delete does not happen
This branch contains the necessary fixes (not my work): https://raw.githubusercontent.com/gutschik/google-photos-delete-tool/master/delete_photos.js
Just seen this update, tried out the updated code works fine on Chrome 89.0.4389.82, thanks for fixing, hope this code will be promoted for other users
Same issue here. But used the above modified script and it runs wonderfully!!!!! Thanks!!
Looks like you need to update the button[title="Delete"]
to button[aria-label="Delete"]
.
Looks like you need to update the
button[title="Delete"]
tobutton[aria-label="Delete"]
.
This solution works perfectly. Thanks!
Great script! Unfortunately, I also ran into issues with delete not working. I made a few changes to help me delete over 40K photos.
- I changed my page zoom from 100% to 25% which loaded more checkboxes at once.
- I increased the timeouts to handle the increase of checkboxes
- I removed setInterval! SetInterval causes the deletion process to restart every 7 seconds regardless of the script finishing the last delete. SetInterval caused conflicts, where the script was effectively stepping on itself, unchecking checked boxes.
I'm posting my changes below.
Modified Code
// How many photos to delete?
// Put a number value, like this
// const maxImageCount = 5896
const maxImageCount = "ALL_PHOTOS";
// Selector for Images and buttons
const ELEMENT_SELECTORS = {
checkboxClass: '.ckGgle',
deleteButton: 'button[aria-label="Delete"]',
confirmationButton: '#yDmH0d > div.llhEMd.iWO5td > div > div.g3VIld.V639qd.bvQPzd.oEOLpc.Up8vH.J9Nfi.A9Uzve.iWO5td > div.XfpsVe.J9fJmf > button.VfPpkd-LgbsSe.VfPpkd-LgbsSe-OWXEXe-k8QpJ.nCP5yc.kHssdc.HvOprf'
}
// Time Configuration (in milliseconds)
const TIME_CONFIG = {
delete_cycle: 12000,
press_button_delay: 8000
};
const MAX_RETRIES = 10;
let imageCount = 0;
let checkboxes;
let buttons = {
deleteButton: null,
confirmationButton: null
}
let deleteTask = () => {
let attemptCount = 1;
do {
checkboxes = document.querySelectorAll(ELEMENT_SELECTORS['checkboxClass']);
} while (checkboxes.length <= 0 && attemptCount++ < MAX_RETRIES);
if (checkboxes.length <= 0) {
console.log("[INFO] No more images to delete.");
clearInterval(deleteTask);
console.log("[SUCCESS] Tool exited.");
return;
}
imageCount += checkboxes.length;
checkboxes.forEach((checkbox) => { checkbox.click() });
setTimeout(() => {
console.log("[INFO] Deleting", checkboxes.length, "images");
buttons.deleteButton = document.querySelector(ELEMENT_SELECTORS['deleteButton']);
buttons.deleteButton.click();
setTimeout(() => {
buttons.confirmation_button = document.querySelector(ELEMENT_SELECTORS['confirmationButton']);
buttons.confirmation_button.click();
console.log(`[INFO] ${imageCount}/${maxImageCount} Deleted`);
if (maxImageCount !== "ALL_PHOTOS" && imageCount >= parseInt(maxImageCount)) {
console.log(`${imageCount} photos deleted as requested`);
console.log("[SUCCESS] Tool exited.");
return;
} else { setTimeout(deleteTask, TIME_CONFIG.delete_cycle) }
}, TIME_CONFIG.press_button_delay)
}, TIME_CONFIG.press_button_delay)
};deleteTask();
Thanks Sandro, it works
Thanks Sandro! works like a charm!
The language needs to be English otherwise it will not find the "delete" button