Skip to content

Instantly share code, notes, and snippets.

@JaosnHsieh
Created December 30, 2023 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JaosnHsieh/5aee429d2ce6a4e1fa10e2632ee98252 to your computer and use it in GitHub Desktop.
Save JaosnHsieh/5aee429d2ce6a4e1fa10e2632ee98252 to your computer and use it in GitHub Desktop.
google photos delete all photos day by day
/* 2023.12.29 google photos delete all photos day by day
1. visit google photos
2. replace the buttons css selectors first by manualy right click and see current selectors
3. run the script on console
*/
// List of events to trigger
const events = ['click'];
// Function to trigger event
function triggerEvent(element, eventName) {
var event = new Event(eventName, {
'bubbles': true,
'cancelable': true
});
element.dispatchEvent(event);
}
function wait(ms = 1000) {
return new Promise((ok)=>{
setTimeout(ok, ms);
});
}
const clickDelete = () => {
const button = document.querySelector(`#yDmH0d > c-wiz > div.u5a4d.QtDoYb.KWdEHf.g7of6e.maPcY > div > div.c9yG5b.txMZRd > div > div:nth-child(4) > span > button`);
if(!button) console.error('no delete button');
if (button) triggerEvent(button, 'click');
};
const clickConfirm = () => {
const button2 = document.querySelectorAll(`.VfPpkd-LgbsSe`)[4];
if(!button2) console.error('no confirm button');
if (button2) triggerEvent(button2, 'click');
}
async function select() {
const checkboxes = document.querySelectorAll('[role="checkbox"]:not(:checked)');
if (!checkboxes[0]) console.error('no checked box');
if (checkboxes[0]) triggerEvent(checkboxes[0], 'click');
}
async function run(){
select();
await wait(2000);
clickDelete();
await wait(2000);
clickConfirm();
await wait();
}
setInterval(run,10000);
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment