forked from mrishab/google-photos-delete-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_photos.js
48 lines (37 loc) · 1.49 KB
/
delete_photos.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Selector for Images and buttons
const ELEMENT_SELECTORS = {
checkboxClass: '.ckGgle',
deleteButton: 'button[title="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.DuMIQc.kHssdc.HvOprf'
}
// Time Configuration (in milliseconds)
const TIME_CONFIG = {
delete_cycle: 7000,
press_button_delay: 1000
};
let imageCount = 0;
let checkboxes;
let buttons = {
deleteButton: null,
confirmationButton: null
}
let deleteTask = setInterval(() => {
checkboxes = document.querySelectorAll(ELEMENT_SELECTORS['checkboxClass']);
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() });
console.log("[INFO] Deleting", checkboxes.length, "images");
setTimeout(() => {
buttons.deleteButton = document.querySelector(ELEMENT_SELECTORS['deleteButton']);
buttons.deleteButton.click();
setTimeout(() => {
buttons.confirmation_button = document.querySelector(ELEMENT_SELECTORS['confirmationButton']);
buttons.confirmation_button.click();
}, TIME_CONFIG['press_button_delay']);
}, TIME_CONFIG['press_button_delay']);
}, TIME_CONFIG['delete_cycle']);