google-photos-delete-tool icon indicating copy to clipboard operation
google-photos-delete-tool copied to clipboard

Add delete album/folder feature.

Open wilyarti opened this issue 3 years ago • 3 comments

Hey bro thanks for the awesome script.

I wrote a quick one to delete the folders/albums as well (maybe you can add it as a feature).

It probably needs some tweaking to make sure it runs smoothly on slower computers.

Here is the code:

var intervalId = window.setInterval(function () { deleteAlbum() }, 6000);

var albums = 0; var albumNumber = document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb').length;

function deleteAlbum() { // Get our first album and click it setTimeout(function () { document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb')[2].click(); }, 500);

setTimeout(function () {
    document.getElementsByClassName('z80M1 o7Osof')[6].dispatchEvent(new MouseEvent("mousedown", {
        bubbles: true,
        cancelable: true,
        view: window
    }));
}, 1500);


// Get our delete button and click it
setTimeout(function () {
    document
        .getElementsByClassName('z80M1 o7Osof')[6].dispatchEvent(new MouseEvent("mouseup", {
        bubbles: true,
        cancelable: true,
        view: window
    }));
}, 2500);


// Confirm deletion
setTimeout(function () {
    document
        .getElementsByClassName('VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ nCP5yc AjY5Oe kHssdc HvOprf')[0].click();

}, 4000);

// Confirm deletion
setTimeout(function () {
    currentAlbums = document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb').length;
    console.log("Current album number: " + currentAlbums);
    console.log("Old album number: " + albumNumber)
    if (currentAlbums < albumNumber) {
        albums++;
        console.log(albums + " deleted.");
    } else {
        console.log("Error deleting album. Aborting")
        clearInterval(intervalId)
    }
}, 5500);

}

wilyarti avatar Apr 16 '21 04:04 wilyarti

Thank you! This helped me delete 83 albums.

johnsimcall avatar Nov 21 '22 21:11 johnsimcall

Its able to do almost all automation but at end it is throwing error saying "Error deleting album. Aborting"

can you please see if this is still working code or not? @wilyarti

lorvent avatar Jan 10 '23 14:01 lorvent

var intervalId = window.setInterval(function () { deleteAlbum() }, 6000);

var albums = 0; var albumNumber = document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb').length;

function deleteAlbum() { // Get our first album and click it setTimeout(function () { document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb')[2].click(); }, 500);

setTimeout(function () {
    document.getElementsByClassName('z80M1 o7Osof')[6].dispatchEvent(new MouseEvent("mousedown", {
        bubbles: true,
        cancelable: true,
        view: window
    }));
}, 1500);


// Get our delete button and click it
setTimeout(function () {
    document
        .getElementsByClassName('z80M1 o7Osof')[6].dispatchEvent(new MouseEvent("mouseup", {
        bubbles: true,
        cancelable: true,
        view: window
    }));
}, 2500);


// Confirm deletion
setTimeout(function () {
    document
        .getElementsByClassName('VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ nCP5yc AjY5Oe kHssdc HvOprf')[0].click();

}, 4000);

// Confirm deletion
setTimeout(function () {
    currentAlbums = document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb').length;
    console.log("Current album number: " + currentAlbums);
    console.log("Old album number: " + albumNumber)
    if (currentAlbums < albumNumber) {
        albums++;
        console.log(albums + " deleted.");
    } else {
        console.log("Error deleting album. Aborting")
        clearInterval(intervalId)
    }
}, 5500);

}

Can you update this script?

leonguyen52 avatar Apr 13 '23 02:04 leonguyen52