Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selects images, doesn't seem to delete them #32

Open
apple-corps opened this issue Mar 10, 2021 · 9 comments
Open

Selects images, doesn't seem to delete them #32

apple-corps opened this issue Mar 10, 2021 · 9 comments

Comments

@apple-corps
Copy link

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)

@simkin
Copy link

simkin commented Mar 12, 2021

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

@sameclarke
Copy link

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

@bluemantwo
Copy link

Same issue here. But used the above modified script and it runs wonderfully!!!!! Thanks!!

@krivaten
Copy link

krivaten commented Apr 7, 2021

Looks like you need to update the button[title="Delete"] to button[aria-label="Delete"].

@jiftechnify
Copy link

Looks like you need to update the button[title="Delete"] to button[aria-label="Delete"].

This solution works perfectly. Thanks!

@sandro
Copy link

sandro commented Apr 28, 2021

Great script! Unfortunately, I also ran into issues with delete not working. I made a few changes to help me delete over 40K photos.

  1. I changed my page zoom from 100% to 25% which loaded more checkboxes at once.
  2. I increased the timeouts to handle the increase of checkboxes
  3. 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();

@garyson03152003
Copy link

Thanks Sandro, it works

@cocoonkid
Copy link

Thanks Sandro! works like a charm!

@gampam2000
Copy link

The language needs to be English otherwise it will not find the "delete" button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants