-
-
Save mturilin/dd649f883458846052957ad5fe5d1e27 to your computer and use it in GitHub Desktop.
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()
Thanks a lot. The last script given by @dcepelik mostly works, but I needed to change the '//span[text()="Move to trash"]'
to '//span[text()="Move to bin"]'
since the text has changed in UI.
Also, just a tip for anyone clearing their gallery. If you zoom out in the browser, it seems works faster as it deletes more images in every iteration. But zooming out too much caused issues where it was deleting too many images every time, and the trashing dialog wouldn't go away before it tried to delete more pictures, causing it to fail. So, experiment a little to find the sweet spot.
Thanks for this script there have been slight changes in html tags , here is the updated script