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 hidden or 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)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.