Skip to content

Commit

Permalink
Update delete_photos.js
Browse files Browse the repository at this point in the history
awaitable scrolling page
  • Loading branch information
shtse8 authored Jan 28, 2024
1 parent ecfbc58 commit 5d041e5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions delete_photos.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const maxCount = 5000;
const counterSelector = '.rtExYb';
const checkboxSelector = '.ckGgle';
const checkboxSelector = '.ckGgle[aria-checked=false]';
const photoDivSelector = ".yDSiEe.uGCjIb.zcLWac.eejsDc.TWmIyd";
const deleteButtonSelector = 'button[aria-label="Delete"]';
const confirmationButtonSelector = '#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';
Expand Down Expand Up @@ -31,8 +31,13 @@ async function deleteGooglePhotos() {
};

// Scrolls the photo list to the top
const scrollPhotoListBy = (height = 0) => {
document.querySelector(photoDivSelector).scrollBy(0, height);
const scrollPhotoListBy = async (height = 0) => {
const photoDiv = document.querySelector(photoDivSelector);
await waitUntil(() => {
const top = photoDiv.scrollTop;
photoDiv.scrollBy(0, height);
return photoDiv.scrollTop == top + height
});
};

// Waits until a specific condition is met, then returns the result
Expand Down Expand Up @@ -66,7 +71,7 @@ async function deleteGooglePhotos() {
while (true) {
try {
const checkboxes = await waitUntil(
() => [...document.querySelectorAll(checkboxSelector)].filter(x => x.ariaChecked == 'false'),
() => [...document.querySelectorAll(checkboxSelector)],
x => x.length > 0
);
let count = getCount();
Expand Down

0 comments on commit 5d041e5

Please sign in to comment.