Created
March 29, 2020 22:04
-
-
Save mturilin/dd649f883458846052957ad5fe5d1e27 to your computer and use it in GitHub Desktop.
Delete all Google Photos
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
for(i = 1; i<=9999; i++) { | |
console.log("Iteration # --> " + i); | |
document.querySelectorAll('div[role=checkbox]').forEach(div=>div.click()); | |
document.querySelectorAll('div[aria-label*="Select all photos"]').forEach(div=>div.click()); | |
await new Promise(r => setTimeout(r, 3000)); | |
try{console.log("Selected documents count for iteration [" + i + "]: " + document.evaluate('/html/body/div[1]/div/c-wiz/c-wiz[2]/span/div[1]/div/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText);}catch(ex){/*do nothing*/} | |
document.querySelector('button[title=Delete]').click(); | |
await new Promise(r => setTimeout(r, 5000)); | |
document.evaluate('//span[text()="Move to trash"]', document, null, XPathResult.ANY_TYPE, null ).iterateNext().click(); | |
//wait for new images to load | |
await new Promise(r => setTimeout(r, 15000)); | |
} |
Thanks for this. I made some updates to make sure it works with the current UI, and made it a bit more robust. Note, I don't think I've ever written JS before, so I eyeballed this:
async function googleDontBeEvilAndLetMeJustDeleteMyPhotosFFS() {
for (;;) {
document.querySelector('a[href="./explore"]').click();
await new Promise(r => setTimeout(r, 5000));
document.querySelector('a[href="./"]').click();
await new Promise(r => setTimeout(r, 5000));
document.querySelectorAll('div[role=checkbox]').forEach(div => div.click());
document.querySelectorAll('div[aria-label*="Select all photos"]').forEach(div => div.click());
await new Promise(r => setTimeout(r, 5000));
d = document.querySelector('button[aria-label=Delete]');
if (!d)
continue; // try again
d.click();
b = null;
do {
await new Promise(r => setTimeout(r, 1000));
console.log("Looking for the stupid button");
b = document.evaluate('//span[text()="Move to trash"]', document, null, XPathResult.ANY_TYPE, null).iterateNext();
} while (!b);
b.click()
await new Promise(r => setTimeout(r, 5000));
}
}
await googleDontBeEvilAndLetMeJustDeleteMyPhotosFFS()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this script there have been slight changes in html tags , here is the updated script